If you are looking for simple but effective solution to refresh data in ADF, you might be interested to check ADF Poll component. This component integrates well with ADF fragments - reload event is isolated in the scope of fragment and not distributed to entire page, means whole page will not be refreshed, but only fragment. I will demo this below with example.
Sample application with ADF Poll component configured to refresh Employees table only - ADFPollFragmentApp.zip.
Employees fragment implements ADF table and Poll components:
Poll is set to initiate reload event every 5 seconds by default. It will stop sending reload events after 600000 seconds. PollListener is defined to implement reload logic:
PollListener re-executes VO SQL for the table and at the end sends Partial Trigger event to perform visual refresh for the Panel Collection UI component containing table with Employees data:
VO is re-executed by accessing iterator bindings from Page Definition:
Main page includes ADF region where Poll component is configured and additionally it contains another table component. There is one more table included to prove that data reload event is not distributed outside of the fragment:
We can see how it works. Open Departments tab from the main page, where no Poll component is configured and select any row from the table - remember your selection, we are going to check it later:
Go to the Employees tab and there check current salary value for Lex De Haan employee. Salary value is 17007:
Open database table and change salary value for the same employee to be 1500, commit your changes:
Switch back to page and you will see that during next data reload Poll event - change will be fetched to the UI:
Similar if you create new record and commit it in the database:
This record will appear in the UI automatically for you:
If you go to Departments, previously selected row still remains correct - this means Poll component was distributing reload event only in the scope of the fragment:
Sample application with ADF Poll component configured to refresh Employees table only - ADFPollFragmentApp.zip.
Employees fragment implements ADF table and Poll components:
Poll is set to initiate reload event every 5 seconds by default. It will stop sending reload events after 600000 seconds. PollListener is defined to implement reload logic:
PollListener re-executes VO SQL for the table and at the end sends Partial Trigger event to perform visual refresh for the Panel Collection UI component containing table with Employees data:
VO is re-executed by accessing iterator bindings from Page Definition:
Main page includes ADF region where Poll component is configured and additionally it contains another table component. There is one more table included to prove that data reload event is not distributed outside of the fragment:
We can see how it works. Open Departments tab from the main page, where no Poll component is configured and select any row from the table - remember your selection, we are going to check it later:
Go to the Employees tab and there check current salary value for Lex De Haan employee. Salary value is 17007:
Open database table and change salary value for the same employee to be 1500, commit your changes:
Switch back to page and you will see that during next data reload Poll event - change will be fetched to the UI:
Similar if you create new record and commit it in the database:
This record will appear in the UI automatically for you:
If you go to Departments, previously selected row still remains correct - this means Poll component was distributing reload event only in the scope of the fragment:
3 comments:
I was in a call with Oracle support and they mentioned that this should not be used for performance reasons. Your approach looks sound, so looking for your opinion on serious performance implications as commented by Oracle support.
I dont see any performance issues (unless there are some hidden ones, known to Oracle support), and by the way this is how Oracle Enterprise Manager works to refresh data as well.
Of course this component should be used smartly - only for such fragments, where user is supposed to see data change after status changes in DB, etc. You should not use just everywhere across application.
Andrejus
Hi This example is very nice and its working for me when I am using oracle db but when I am using mysql
the page is getting refresh but attribute value remains the same.
Can you please give me the hint to work this for mysql.
Post a Comment