Tuesday, October 31, 2006

Spring Framework:The advantages

Spring Framework:
The main aim of Spring framework is to elliminate the complexities of writing a complex J2EE application.e.g in a typical J2EE env, if you want to access EJB, then Spring takes away the pain of using JNDI or if you need to use JDBC, then it takes away the pain of using "try" "catch" "finally" blocks etc.

1)-Helps designing and organizing the components(web-tier as well as
the server side bsuiness components) in a much layered manner(Just like BC4J, but more than that)
2)-It uses simple POJOs as the business logic class instead of EJBs.
3)-It has got a greater support for Dependency Injection as each layer of
code in Spring framework works in isolations. So essentially developers
can pull out any layer and test them in isolation.
4)-It has a great JDBC wrapper in it.
5)-It has Inversion of Control container and AOP.(Please google for these two terms)
6)-Most importantly, it provides an env to have a Test Driven Development.

Listen to this webcast by Rod Johson, the founder of Spring Framework.

BC4J:transaction-level postChanges() is hazardous!!

The transaction-level postChanges() method that exists to force the transaction to post unvalidated changes without committing them is not recommended for use in web applications unless you can guarantee that the transaction will definitely be committed or rolled-back during the same HTTP request. Failure to heed this advice can lead to strange results in an environment where both application modules and database connections can be pooled and shared serially by multiple different clients.

Friday, October 27, 2006

Gen Tech:How to copy HTML data from browser to an Excel sheet.

There is a pretty simple way of exporting an HTML data into an Excel file without much effort of writing any program.
I have tested many times and it works.
Note: It works only in IE.

Please follow the steps below.
  • 1)-Open MS Excel in your pc and keep it in taskbar.
  • 2)-Access any URL which gives an HTML table output.
  • 3)-Select the whole of the data you want to export.
  • 4)-After selecting just see the mouse where it is. DOnt move the mouse and by pressing the left button drag the mouse towards the taskbar to the top of the Excel icon.
  • 5)-Dont yet release the mouse even if the mouse icon changes.
  • 6)-Keep the left button pressed and keep on top of the excel button.It automatically maximizes the Excel spreadsheet.
  • 7)-Dont release the mouse button in the whole process.
  • 8 )-Just drag the mouse with left button pressed towards the start of the Excel sheet and release the mouse button.
  • Thats all..
  • The whole trick is not to release the left mouse button.
  • Please try in IE and see if it helps you. I have tried number of times.

Thursday, October 19, 2006

Oracle Apps:Programmatically Compile a KFF View

Sometimes its required an API to call from our PL/SQL package to compile the KFV view in Apps.
request_id := fnd_request.submit_request('FND',
'Compiling Flexfield',
'K', -- Type of FF
, -- Application short name
p_ff_name, -- FF name
TO_CHAR(l_flex_num) -- ID_Flex_Num);

Wednesday, October 18, 2006

Java:Programmatically compiling a java file

The class com.sun.tools.javac.Main.compile provides the programming interface for javac.
sample code is :

int errorCode = com.sun.tools.javac.Main.compile(new String[] {
"-classpath", "bin",
"-d", "/temp/dynacode_classes",
"dynacode/sample/Foo.java" });

errorCode return 0 for Sucess and some non-zero number for any compilation failure.

Also to print the compilation error messages to an o/p file,
it has another overloaded method.

// Defined in com.sun.tools.javac.Main
public static int compile(String[] args);
public static int compile(String[] args, PrintWriter out);

Perl: XML Parsing program in Perl using XML module

Here is a sample code snippet on how we can easily parse an XML doc in PERL (tested in Linux).


##Programs for XML parsing.

use XML::Parser;

my $p = XML::Parser->new(Style => "Tree");
my $input = '/home/ammishra/perl/ip.xml';

traverse( $p->parsefile( $input ) );

sub traverse
my $node = shift;
while ( defined ( my $element = shift @{ $node } ))
my $child = shift @{ $node };
if ( ref $child ) # if $child is yet another arrayref node
my %attr = %{ shift @{ $child } };
# yank the attributes out of the grandchild
print "$element has attributes @{[ %attr ]}\n";
traverse( $child );
# child element is now just a list of element/children pairs
else # otherwise, if $child is just some text
print "$child\n";

BC4J+OA Framework:Get number of rows in a ViewObject without fetching all rows to middletier

In BC4J(Business Component for Java),Lets assume, we have a View Object(VO) based on a SQL.
The code below prints i as "0" i.e no rows are fetched to the middle tier.

int i = vo.getFetchedRowCount();

Now use
getRowCount() instead of getFetchedRowCount();
and it would print correct no of records.

executeQuery() doesn't actually fetch the first batch of rows right then and there. The next operation that requires a query (such as first(), for example) will do this. getRowCount() forces the last() row to be retrieved. But getRowCount() might be a costly affair in cases where we dont want the rows to be fetched from the DB, say we just want the count.

using getEstimatedRowCount() if you want the count without fetching all the rows, solves the same purpose.

Oracle Apps:Open a Conc program Output in your favourite Program

There is a profile option called "Viewer:Application for Text" in Apps.
Logon to Oracle Applications , use System Administrator Responsibility and Navigate as :-
Install -> Viewer Options
to open the Form "Viewer Options"

Then do the entry as shown below :-

File Format Mime Type Description
Text application/msword Microsoft Word(.doc)
Text application/vnd.ms-excel Excel (.xls)
Text text/plain Notepad(.txt)

Then ensure that the profile option
Viewer: Application for Text
is set to BLANK at the Site Level.

Then ensure that the profile option
Viewer: Text
is set to Browser at the Site Level

Submit a Concurrent Request that generates Text Output File
Click on View Output Button
You will see a LOV showing
Microsoft Word(.doc)
Excel (.xls)