Tuesday, October 11, 2011

Create Row in a Table after leaving an input Field (ValueChangeListener usage) ADF 11g

Hi,
This is a sample application demonstrating the following case:
We have an af:table with rows from a View Object. What we want is to create a new row right after leaving an input Field.
What we are going to do is to make use of the valueChangeListener.
First we are going to do is to create a simple page.
For this example, the HR schema is used and more specifically the Regions Table.

Download the Sample Application.

After creating the appropriate Business components (entities and view objects), we will create a jspx with its pageDefinition. In the jspx we drag and drop the Regions View Object as a table.
In the page Definition, we add the operation binding of CreateInsert.


After that, we select the input field we want to use for the creation of the new row and we create a valueChangeListener. If no Backing Bean is present the wizard will help us create one on the fly and very easily. Additionally, we have to set this field to autoSubmit=true;
Furthermore, we have to create a binding of the Regions table because we need it in order to refresh the table right after the creation of the row. The refresh is needed because we want to show to the user (actually refresh the UI)  that the row is already created and correctly shown.


The last this left is to write some code in order to actually create the new row right after leaving the input field (via pressing tab lets say)

The code to write in the ValueChangeListener is fairly small and rather easy. All we have to do is call the CreateInsert operationBinding and then refresh our table.





And that is it.
When you run the application you will see that after changing a value and pressing tab a new row will appear on the table. Note that this row is not posted in the DB and does not exist there. This sample application has no other operations like commit or rollback included.

Download the sample Application.

Regards.


1 comment:

  1. Dear Dimitris
    Thanks for this helpful post
    how about to copy values from others inputs fields to this new row

    execute some thing like cursor to fill this table

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...