Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Monday, January 25, 2010

Updating a Declarative Component in ADF 11g

I have an adf application built in 11g. It uses a custom component which I developed for this app. Recently, I got the need to add an additional attribute in the component. So, thought to blog about the way I did it without any issues.

1. Open your custom declarative component project.
2. Add the desired attribute and deploy it to your desired path.
3. Stop the running wls.
4. Open your main project ( consumer project). Go to properties.
5. From the libraries and class path delete the existing entry for the component.
6. Save the changes and close the jdeveloper completely.
7. Open the consumer project's ViewController.jpr in a text editor.
8. Remove all the entries containing any reference to your custom component library.
9. Reopen jdev and then go to resource pallet.
10. Add a file system connection and select the directory you generated the custom declarative component jar.

That's it. It should reflect your new updates component nicely.

Thursday, December 31, 2009

Deploying ADF 11g application in weblogic 10.3

Today, I was trying to deploy my ADF 11g web application to a weblogic server. So the first step was to right click on View Controller project and go to deploy option. This created a war file for me as npe.war . I went to weblogic console and in the deployments choose install option and provided the path of npe.war. After few next next and finish I saw an error saying:

java.lang.ClassNotFoundException: oracle.adf.library.webapp.ResourceServlet

So, on hunting for a solution finally found that I used the wrong way of deployment. Instead of deploying View-Controller project as a war file I should have deployed the whole application as an ear file. So to do so there is an application menu in the jdeveloper. Select deploy option from there and choose deploy to ear file. So far so good I went again to the weblogic console deleted the old npe.war web app and this time installed npe.ear. After reaching the finish step on hitting finish I saw a new set of errors saying:

java.security.PrivilegedActionException: wenlogic.common.ResourceException:
java.security.PrivilegedActionException: wenlogic.common.ResourceException:
No credential mapper entry found for password indirection user=system for data source NPE

So, another hunt on web resulted into another change I need to do before deploying the app as an ear. To avoid this error you need to go to Application --> Application properties and in the new window uncheck Auto Generate and synchronize weblogic-jdbc.xml Descriptors during deployment.

That's it.. now deploying the ear this time should successful. Please comment if you found any other issues while deploying your ADF application to weblogic.

Tuesday, October 13, 2009

Getting handle to HttpSession in ADF

However, in general you should not need to get HttpSession programmatically in ADF.

But sometimes you need and here is how:

FacesContext context = FacesContext.getCurrentInstance();

HttpSession session  = (HttpSession)context.getExternalContext().getSession()



Wednesday, September 9, 2009

Creating code templates in Jdeveloper 11g


Jdeveloper has a great feature called code templates. Jdeveloper comes with some pre-seeded code templates and provided the capability to users to define their own.

A code template is kind of short cut to generate a boiler plate code which you use heavily. For example, a for loop. You can simply type in code fori and press Ctrl + enter and it will automatically generate:

for(i=0;i<0;i++){
}

This could be a huge time saving. If you want to have look at what all code templates are available then you can go to Tools-->Preferences --> Code Editor -->Code templates. You will see a good number of typically used code templates. Some are:

To define your own code template stay in the same place and click on the Add button.
So, let say we want to define a code template for iterating using a RowSetIterator and the code could be like:

ViewObject vo = null; //actual code will get the instance from application module
RowSetIterator itr = null;
if (null != vo.findRowSetIterator("test")) {
itr = vo.findRowSetIterator("test");
}
else
{
itr = vo.createRowSetIterator("test");
itr.reset();
}

while(itr.hasNext())
{
Row row = itr.next();
//your row specific code here
}

So, to define it just type a short cut name "ri" and in description "iterate using RowSetIterator on VO"

Below in the code just paste the code given below.
ViewObject $vo$ = null; //get view object
RowSetIterator $itr$ = null;
if (null != $vo$.findRowSetIterator("test")) {
$itr$ = $vo$.findRowSetIterator("test");
}
else
{
$itr$ = $vo$.createRowSetIterator("test");
$itr$.reset();
}
while($itr$.hasNext())
{
Row $row$ = $itr$.next();
$end$
}

Where ever, you see a word enclosed in $$ that is a kind of place holder and will replace with some actual value when you will use it. There is a variables tab. As soon as you paste the above code in the code tab you will see some variables are automatically defined. In the variables tab you can change the default values as well. By default it will assign the value same as the text enclosed in $$ in your code template.

There are situations like in the above template when you may need to import some classes. To do that just go to imports tab and paste below code:
oracle.jbo.Row
oracle.jbo.RowSetIterator
oracle.jbo.ViewObject

So, above 3 classes will be automatically imported when you will type ri and press ctrl + enter along with the desired code.