ADF 11g: programmatically configuring sort for rich table
A recent requirement on one of our ADF 11g projects: we want to gather a number of settings a user has applied to the rich table in one of the pages. These settings include position, width and visibility of columns (supported by change persistence) and custom data filter, sort configuration and highlight condition. These latter settings are not part of change persistence out of the box. An additional requirement is that this collection of settings is to be saved under a label and to be made available to all users for selection when they view that same table.
I like these requirements. They are tangible, concrete and add fun(ctionality) to the application that directly pleases the end users. With ADF 11g, it is not an extremely difficult requirement – it seems.
One of the aspects mentioned here – sort setting – requires us not only to intercept or capture changes in sort settings – which sortListener on the columns of the table will do nicely – but also the programmatic application of sort settings when the table is rendered and a ‘user saved packet of table settings’ is selected.
In this article I take a very brief look at how to programmatical set the sorting condition on the rich table’s columns.
Visually this functionality can be illustrated like this:
The table is shown with data that is currently sorted by Job. When the user clicks the button Sort by Name, our programmatic ‘set the sort property on the table’ code is invoked and the data is re-rendered, sorted by Name:
The underlying code is quite simple.
I have created a class TableManager and based on that class a managed bean called tableManager. This class has a property RichTable table with setter and getter method.
The <af:table> is bound to the managed bean through an EL expression:
The TableManager class contains a method sortByName:
This method creates a new sort criterion, based on the name property (which is one of the properties in the Employee class that is used for the objects in hrmBean.employees). This criterion is added to an otherwise empty list that is set as SortCriteria on the RichTable. Next, the table is added as partial target to the ADFFacesContext, which means that when the request completes, the table component is refreshed in the browser.
Finally, the button has its action property (could have been the actionListener as well) set to refer to the sortByName method:
When the button is pressed, the tableManager bean is invoked, method sortByName is executed, the sortCriteria on the table are manipulated and the table gets refreshed. Job done.
- ADF 11g Rich Client Components – programmatically adding a ShowPopupBehavior
- Great Oracle Forms 'plugin' – multirecord table column resize/sort/move around
- Rich Validation functionality in Oracle ADF Faces 11g Rich Components
- Rapid development of Rich JSF Web applications on top of EJB/JPA persistence (JSF on Rails – Demo 1)
- ADF: (Automatic) Partial Page Rendering across Taskflows
- ADF client-side architecture – Select All
- ADF 18.104.22.168 : The return of the paging table (… and more ….)
- ADF DVT Speed Date: Interactive Bubble Graph
- Book Review : Oracle ADF Real World Developer’s Guide
- The ultimate ADF event of 2012: The AMIS Master Class Advanced ADF – Christmas Special (Friday 21st of December)
- Maak bij AMIS als eerste kennis met Oracle ADF Mobile!
- ADF Mobile : Your First Navigation and Device Interaction
- ADF Mobile is now Generally Available
- ADF 11g Training Applicatie Ontwikkeling.