Friday, September 21, 2012

ADF Create and CreateInsert Operations for ADF Table

I bet every ADF developer was wondering in his life at least once - what operation to use to insert new row into ADF table - Create or CreateInsert. This one is a must question from developer who starts ADF development. Answer - use CreateInsert operation to insert new rows into ADF table or form. Create operation works with form component only. However, this is not so obvious - I saw such situations when developers where stuck for some time, because they were unable to implement new row insertion (just because of using Create, instead of CreateInsert). It looks like CreateInsert operation calls additional functionality to push newly created record and really display it in ADF table just after operation is completed. But Create operation is missing that part. I will describe in this post with example.

Download test case application - CreateInsertSampleApp.zip. Test case contains simple page, both operations Create and CreateInsert are implemented directly from Data Control:


There is only one page, where I have both ADF form and table. Same Create and CreateInsert operations are applied for both blocks:


Operations are defined in Page Definition file:


Firstly we test Create operation - press Create button for the table:


There is no new row rendered in the table, but new row was inserted only into form component - this is a problem most of new ADF developers are facing. User gets confused - press second time on Create and ADF will show validation errors for missing required fields in the form:


CreateInsert operation behaves much better - press CreateInsert button and you will see new blank row inserted into ADF table. User is ready to type data and commit it. Also new row was inserted into form component - this means CreateInsert works for form and table:

8 comments:

MinBzid said...

Hello Andre!
i built a tree which has many levels!! so i need to insert values for a specific level so i wonder if i can achieve this with -> create!i need to create a new row and in the same time to keep the Parent_id "the level" i am at..

Best Regards

Francesco Savino said...

Hello Andrejus , but what is the real kind of row that ViewObject retain when I use the Create operation ? it is a row with a corresponding entity but just non commited , is a row just inside the ViewObject's iterator or is just a row retained by ADF form ?
And How I can retrive this row just created if don't have holder variables at pageDef (this is the point ! I rely on some place where row is maintained ..)

thanks

Anonymous said...

Hi,
I cannot download the test case application.
I am getting Error 404
The requested URL /files/CreateInsertSampleApp.zip was not found on this server
THanks

Andrej Baranovskij said...

Hi,

All old samples can be downloaded from Google Archive - https://code.google.com/archive/p/jdevsamples/downloads

Andrejus

Anonymous said...

Hi,
Thanks for your response
Do you have similar test case in 11.1.1.7.0?
It's trying to convert JSF 1.0 to 1.2

THanks

Anonymous said...

Hi

Can help to share me the fusionFx skin file attached with the test case?
Thanks

Andrej Baranovskij said...

It is packaged with ADF.

Andrejus

Alex said...

Hi Andrejus!

We are using the open-blank-form pattern: create a new blank row (with createRow, not with createInsertRow) in viewObject when form is opened and bind it to the form via IterBinding.
The problem we are facing is that this new row becomes a stray row if the user decides to simply navigate to another page, bypassing the cancel button (this button explicitly removes the row).
When the transaction is commited by some other business functionality, this stray row gets inserted into the DB.
Is there a way to prevent the insertion of this stray row?

Thanks