Thursday, March 12, 2009

ADF Faces Rich Client PopUp and Master-Detail

In documentation and tutorials you will usually find classical example of Master-Detail relationship separated into two pages. However, with JDeveloper/ADF 11g more and more frequently we are moving to ADF Faces Rich Client popup based approach. This approach allows us to use Ajax popup for one part of Master-Detail relationship instead of separate page. Of course, frequently Master-Details are implemented on the same page, but I will write in this post about two pages approach transformation into page and Ajax popup.

You can download developed sample application where described approach is demonstrated - PopUpRefreshBackground.zip. When you will run main page, and will press Departments button, you should get similar screen:


In this sample application I have Detail records in the background on main page and Master records are in popup. When user scrolls through Master set and selects row, Detail row set is refreshed in the background automatically. I think such approach is definitely better comparing to two pages. ADF Faces Rich Client popup can applied not only for Master-Detail relationships, you implement in popup search functionality using ADF Query with a short list of results and display full set of results in the background.

In sample application, I have created a form for Detail records and table for Master:


In order to refresh Detail record set from ADF Faces Rich Client popup, you just need to set PartialTrigger on Detail form based on ID of Master table - this means when user will change selection in Master table, Detail form will be refreshed with correct row set.

But, as always there is one trick, I want to tell you about. In 11g, Oracle have introduced automatic PPR functionality defined on Iterator in Page Definition:


I have noticed, when you drag and drop ADF Table from Data Control, JDeveloper sets automatic PPR feature on Iterator:


However, its not always good - there is side effect of this when using row selection functionality in ADF table. Let's say user will scroll to the middle of the table and will select a row:


With PPR feature set on Iterator, ADF table will be automatically refreshed after selection event, and first row of the table will be automatically shown. This behavior is not good, because user will need to scroll to his selected row again:


In order to avoid described side effect, unselect PPR feature on Iterator for this case.

User selects Master row, Detail data is refreshed in the background:


Update 2009/03/13:

I have received very useful hint from Steve Muench today, regarding described side effect of automatic PPR feature. Its just enough to set DisplayRow = selected property for af:table and framework will automatically refocus table for currently selected row, even if it will be in the middle. Here is this property:


Spanish Summary:

En este ejemplo, Andrejus muestra el uso de Lista de Valores para obtener un valor de una Lista. Bien, en estos casos se detalla un comportamiento no deseado debido a una configuraciĆ³n que genera el asistente por default. Por ello Andrejus brinda un tip para solucionar este inconveniente.

1 comment:

sunil said...

"DisplayRow = Selected" will work when RowCountTHreshold is set to 0 on iterator or else it wont work