Home » Java » Enterprise Java » Creating a View Object Row with ADF Bindings CreateInsert action

About Eugene Fedorenko

Eugene Fedorenko

Creating a View Object Row with ADF Bindings CreateInsert action

In this short post I am going to highlight a small pitfall related to a very common approach to create a new record in a task flow.

Let’s consider an example of a simple task flow creating a new VO row, displaying that row on a page fragment and committing the transaction if the user clicks “Ok” button:
 
 
 
 
 
 
 

The CreateInsert method call has been just dragged&dropped from the data control palette. The thing is that if the user does not update any VO attributes in
view1 page fragment, the Commit method call will do nothing. The new row will not be posted to the database.

The reason for this behavior is that the ADF bindings CreateInsert action always creates an entity in Initialized state, which is ignored by the frameworks while committing the transaction. Even if the entity has default values, or it’s Create method is overridden setting the attribute values, it doesn’t matter, the entity will be still in  Initialized state after the
CreateInsert action.

Afterwords, if any VO attributes are modified, the entity gets the New status and the framework will post changes (preform insert statement) while committing the transaction. This behavior is quite logical as in most cases task flows like that create a view object row to get it updated by the user before submitting to the database. However, most cases are not all and if it is needed we can always implement a custom VO method creating/inserting a new row and invoke it instead of the standard CreateInsert action. Like this one:

  public void addNewEmployee() {
    EmployeeViewRowImpl  row = (EmployeeViewRowImpl) createRow();
    insertRow(row);
  }

That’s it!

Published on Java Code Geeks with permission by Eugene Fedorenko , partner at our JCG program. See the original article here: Creating a View Object Row with ADF Bindings CreateInsert action

Opinions expressed by Java Code Geeks contributors are their own.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
Email address:

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz