Sunday, May 9, 2010

CRUD Operations in Oracle ADF 11g Table Without Auto PPR

It seems, quite popular to implement CRUD operations for table component, using separate Popup window, as described in my previous blog post - CRUD Operations in Oracle ADF 11g Table Using PopUp Component. All my latest customers prefer to follow this approach. Its why today I will post improved sample for the same use case. There is an issue, when we want to reflect changes done in editable Popup window back to main read-only table. In order to keep main table in synch, we can set Iterator ChangeEventPolicy to ppr:


This means, each time when data change will happen in Popup window, main read-only table will be refreshed automatically. It works well, but there is one side effect with this approach, unfortunately. Table refresh will happen each time, when user simply selects another record. For simple tables thats Ok, but if we have complex screen with Master-Detail data - screen performance will be down immediately. It will refresh not only Master table, but all dependent Detail tables as well. So, we need to disable ppr for iterator binding:


The question now - how we trigger table refresh. Actually, it is quite straightforward - we need to set PartialTriggers dependency for Panel Collection from Popup and Popup Dialog components. We need to set it from both, because:
  • Popup Dialog component triggers partial refresh on OK event (when we save data)
  • Popup component triggers partial refresh on Popup Cancel event and on Popup fetch event (we can see newly inserted row)
Same logic works in case of custom reusable toolbar component, consuming page can reference Popup and Popup Dialog directly from custom tag library.

Let's set PartialTriggers property for Panel Collection:


PartialTriggers property must be based on two components:


Popup component and Popup Dialog:


Let's see how it works now. There is one record selected in the table:


We select another one, and no table refresh happens - thats what we want:


We can edit data:


Table is refreshed after we close dialog and shows latest changes:


When new row is being inserted, table is pre-populated with new empty row:


Download sample application - TableDialogEdit4.zip.

27 comments:

Baig said...

great post

Amit said...

CUDA is a really very great tool for oracle user. I just love it's UI functionality.

vishal said...

your samples are just gr8.

Andrejus Baranovskis said...

Thanks :)

sankar's said...

hi
Really grate .. but i have one doubt please send one link to build a popup functionality.

Anonymous said...

hi great post.. but i have some problems.. I can't delete / update/insert a data to database.. to sum up i couldnt make crud operations.. i download your application but i dont understand..

Andrejus Baranovskis said...

What error you are getting?

Andrejus

Pamorale said...

Hi Andrejus, I'm trying to replicate what you did, but I can get the bindings for the popup inputs right... where can I learn to do this???
Thanks in advance...

Andrejus Baranovskis said...

Call Red Samurai, if you will manage to find us, we will come for rescue :)

Peter said...

I have tried your sample inside the region, but when I clcik the 'delete' button, the all three lines in the table are disapper, only when i click edit and choose the 'cancel' button, then those not deleted lines are appear again. could you let me know what My problem is? Thanks!

Andrejus Baranovskis said...

What version of ADF you are using?

Andrejus

Anonymous said...

Helo Andrejus,
I have quite the same problem. I have a table with "edit all" editing mode. I use PPR for the iterator. There are some calculations in the table.
For example, value*percentage=result. Those three fields are the columns of the table, all are auto submit, and each has custom value change listener.
My problem is when I change the value (pressing TAB) )in value or percentage or result field, the table always refreshes and lost its focus for the next field.
What I want to achieve is that the table does not lose its focus for the next field when I press TAB.

Any suggestion for this?

Thank You.

Agung

Andrejus Baranovskis said...

You should not user PPR on iterator, but declare PPR on table column by yourself.

Andrejus

Anonymous said...

How to do that?

Thanks..

Anonymous said...

Hi, i got it worked out.. thanks a lot for your help..

Andrejus Baranovskis said...

Great ! :)

Kaamadhenu said...

Hi Andrejus,
Thanks for samples. They are very useful. I have one question though. Do you have a sample for a CRUD ops for Master Table - Detail Table. I need the ops for both master and detail on the same page.No popups or page navigations.
Appreciate your help.

Cheers,
Ravi

Andrejus Baranovskis said...

You can try this sample, may be it will help - http://andrejusb.blogspot.com/2009/03/create-operation-for-master-detail.html

Both Master and Detail on same page.

Andrejus

Mr. Self-Destruct said...

Thumbs Up for your blog!

it helped me with my refresh master-detail tables problem.

set changeventpolicy to ppr and my details tables refresh when change the row on the master table.

Patrik Frankovic said...

Hi Andrejus,
I got really strange behaviour of crud operations in popup component. I'm using Jdev 11g R2.
So, I've got table and popup form for crud operations(like your sample). Both table and form relias on same view instance. And evertything runs smoothely if there's no af:selectonechoice component on form, but if I add some selectonechoice component which list is declared in BC, this selectonechoice control seems to lose all it's data(it hard to explain even). I'm not an adf expert, but also not a beginner, and this error bugs me alot, and tried some googling but withou any success. I've also tried to create new app from scratch and error remains. If you like I could mail you some HR sample which I've created for this purpose?
Regards,
Patrik

Andrejus Baranovskis said...

Hi Patrik,

Yes, please send sample app - I will look through it, may be I will spot something.

Andrejus

sydbrat said...

did anybody get null pointer exception on bindings following this example? the example works but when I my own usecase I get the exception. I am sure some of the things are not getting registered right. It would be nice to have a step by step process of this example. I just copied the code changed values in the source.

Andrejus Baranovskis said...

Please let me know, what exactly step by step? I will try to explain.

Andrejus

sydbrat said...

like, how did you create the popup and how did you tie the popup with the insert/others buttons? How is the backing bean tied to the popup?

Andrejus Baranovskis said...

You can find this info from Oracle dev guide... Its already well described there.

Andrejus

thread said...

THank you for your tutorial...but i want you send me this tutorial describe step by step , how to build CRUD with ADF. I'm new in ADF faces.
Thank you

Anonymous said...

Hey Buddy,
I cant seem to find a way to stop AF: Meassages from auto closing if any kind or ppr or refresh happens on screen. Do you have any clues?