Sunday, September 5, 2010

Open jspx Page in Insert Mode in ADF 11g How To


This is an example of how to enter a form in insert mode.
By default, the ADF queries for data when the user enters a page.

To bypass this, we have to enter the page without quering for any data.

To do this, we have to executeEmptyRowSet() on our View Object before entering the page.

Download the Sample Application.

The before entering the page is easier than you might think
The goal here is to have the page intact with it's default functionality.

The fact that we want to enter the page in insert mode might change at some point. So it is better to have this functionality in a different place.

Besides, the insert mode, affects the model and eventually the page through the bindings.

So, by changing the status of the VO we eventually changing the status of the jspx through the magic bindings.

What we need is this:

As you can see, in our task flow we have a method call as the default activity.

This methodCall calls a method in the Application Module.

The method in the AM is very simple:

     * creates a new record in the Employees View Object.
     * Also executesEmptyRowSet in order not to fetch Data.
    public void enterEmpsInInsertMode(){
     EmployeesViewImpl emps=(EmployeesViewImpl)this.getEmployeesView1();
     emps.executeEmptyRowSet(); //
executeEmpty RowSet not to fetch Data.
     Row newRow=emps.createRow();

This method gets the EmployeesView and does the following:

1) executes empty row set. This will not bring any data to the iterator.
2) creates , inserts and sets it as current in the View Object, which eventually through the bindings will be the current row in the iterator on the page.

This method is exposed in the client Interface of the AM.

The result is this:

If we drag and Drop from our Data Control this method in our taskFlow, it will create a methodCall with its own pageDef and added the method from the AM.

Make sure that the method call is set to be the default activity of your task flow.
Thats it!
It might not be out of the box implementation, but it is a very clear approach.

Here is a screenShot of the result page:

Download the Sample Application.

Update: After FetishCode comment, I have to say that the scope of the example is for the user to be able to rollback and be able to see all the records of the View Object. To achieve this, we must change the property cacheResults of the Iterator in the pageDef of our page to false.

I double checked the application and changed to the correct one. Mistakes happen..


  1. Hi,

    What about dragging and dropping simple CreateInsert Operation from Collection to Task Flow as default activity?

  2. Hi Baig,
    Yes, we could do this but we wanted to execute empty rowSet before doing anything else.


  3. Another option is VO in mode "No Rows" in design time
    I think Your solution is a little round-about solution.

  4. But
    It is always good to learn things. I ignored this way

  5. Hi fetichcode (nice name by the way..) You are right with your comment. The purpose of this post was to give the user the ability to rollback while in insert mode and be able to see all the records of the View Object. with the property you mention, this is not possible. After I saw your comment, I downloaded the sample Application and realized that I didnt change the property cacheResults to the iterator in the pageDef. So the behavior was exactly the same as the property in the VO you mention. I update the post after your comment.


  6. Hii
    If there is a table on the same page(main page),i am not able to view the new added record in the table..if i change the cacheResults of the Iterator in the pageDef as false...and if this is true then no record appears on the page bcoz of emps.executeEmptyRowSet()

  7. Hi
    This article is very useful while creating a page in insert mode. I have one more question though. what if I have to copy a value from the main page to the insert page while inserting a new record. How do I go about doing that. Does any one have any idea. Will appreciate that. Thanks



Related Posts Plugin for WordPress, Blogger...