Monday, April 26, 2010

Iterating a View Object using a secondary RowSetIterator

The recommended way to iterate a View Object is via a secondary RowSetIterator returned after calling createRowSetIterator() on the View Object. It is suggested to call reset() on the RowSetIterator before iterating it. This will move the currency to the slot before the first row. Iterate while calling hasNext() to check for next row availability and subsequently by calling next() to get the next row. When done, call closeRowSetIterator() to close the row set iterator. Failure to use a secondary RowSetIterator when directly iterating the View Object, could lead to end user confusion as the row set currency changes affecting the user interface.

Example:

         // in the context of the AppModuleImpl
       RowSetIterator iterator = viewObject.createRowSetIterator(null);

       iterator.reset();
       while (iterator.hasNext()) {
          Row row = iterator.next();
      
          // process the row here
       }

       iterator.closeRowSetIterator();


Context:

Application Module Implementation class
View Object Implementation class

 

 

Duplicate Row

Sunday, April 25, 2010

how to clear form and insert upon submit button

1)       cretae a commit button actionlistener  with the following backing bean clearForm

 

package bean2;

 

import javax.faces.application.FacesMessage;

import javax.faces.context.FacesContext;

import javax.faces.event.ActionEvent;

import oracle.adf.model.BindingContext;

import oracle.binding.BindingContainer;

import oracle.binding.OperationBinding;

import oracle.jbo.uicli.binding.JUCtrlAttrsBinding;

 

 

 

public class bean2 {

    public bean2() {

        super();

    }

    private BindingContainer bindings;

 

    public void clearForm(ActionEvent actionEvent) {

        // Add event code here...

        BindingContainer bindings = getBindings();

        OperationBinding commit;

        commit = bindings.getOperationBinding("Commit"); // for master view object

       

              

        OperationBinding createInsert;

        createInsert= bindings.getOperationBinding("CreateInsert"); // for master view object

 

       

        if(commit != null)  commit.execute();       

        if(createInsert != null)  createInsert.execute();

 

    }

    public BindingContainer getBindings() {

              return (BindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

          }

        public void setBindings(BindingContainer bindings) {

              this.bindings = bindings;

          }

}

Thursday, April 22, 2010

current date time groovy for ADF

We mostly have created_date or updated_dated column in our data model. The value for these columns is mostly the currentt date (time truncated) or current date and time. To default such values every time you create a row in VO/EO there is excellent support for groovy expressions in ADF.

 

To do so go to your VO/EO .xml file. In overview mode select attributes tab. In that select the attribute you want to default with current system date-time or date. In the value box type one of the below and choose radio as expression.

 

Only date: adf.   currentDate   

Date with Time:  adf.currentDateTime

 

Wednesday, April 21, 2010

Difference between view link and association

In short, View links relates two view objects and associations relates two entity objects. There is no connection between both but view links can be created based on associations or independently without associations.

What is DataBindings.cpx file in ADF

In ADF web application as soon as you drop a databound component on your page a DataBindigs.cpx file gets created. You may wonder what it contains? So, here it is:

 

The DataBindings.cpx keeps track of the individual page definitions files used within the project, as well as the DataControls mapping to such things as ADF Business Components Application Modules.

 

Till Jdeveloper 10.1.3 release there was no way to have multiple DataBindings.cpx files which was very much desirable as the project the size grows and being worked by multiple teams. Jdeveloper 11g added this capability to have multiple DataBindings.cpx files.

 

There is a new file in 11g called adfm.xml which is used to keep track of all such DataBindings.cpx files in the system. So, when breaking your DataBindings.cpx you need to take care to create an entry in the adfm.xml. You also need to make sure to have unique application id attribute value for each entry.

 

Using Groovy to populate sequence value in primary key attribute in ADF 11g

In ADF 11g there is a better and much simpler way to populated primary key attribute of your entity using a db sequence.

 

You can simply to to your entity pk attribute change the default value type to expression and put



(new oracle.jbo.server.SequenceImpl("YOUR_SEQ_NAME",object.getDBTransaction())).getSequenceNumber()

 

Difference between getRowCount and getEstimatedRowCount in ADFount

In ADF applications where a VO is working on large amount of data it is could be a bad impact on using getRowCount to find the number of rows in the VO. The reason is it query the database table every time it is used. So, it incurs you a DB trip.

 

However, getEstimatedRowCount is a bit different. For the first time it queries to DB table using a select * from table query and store the count in the Middle-tier. After that it keeps on adjusting the count within the middle tier whenever row insertion or deletion are performed on the view object.

 

This way it prevents the db trip and is much faster.

 

The downside of this method is it may not be accurate sometimes. Specially, in the scenarios where there are possibilities of data insertion or deletion from backend by some other application at the same time.

 

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.

Dare to Code... : Fine tuning your Application Module in ADF

Abdoul Rahman has sent you a link to a blog:



Blog: Dare to Code...
Post: Fine tuning your Application Module in ADF
Link: http://adfjsf.blogspot.com/2009/09/fine-tuning-your-application-module-in.html

--
Powered by Blogger
http://www.blogger.com/