ADF 11g: Programmatically repositioning columns in a Rich Table


Rich Tables are powerful beasts in ADF Faces. They can present tons of information in many different ways. They allow users an extensive range of manipulation – from reordering and hiding columns, changing column width to sorting and filtering the data presented in the table and detaching the table from its embedding page as well as exporting the data from the table to an Excel file. Pretty impressive. And many of the visual configurations can be stored using Change Persistence across requests and even across sessions.

One specific requirement on a recent ADF 11g project led me to investigating if and how the ordering of columns in a rich table can be manipulated programmatically (rather than having the user to it). Earlier articles on this blog discussed similar challenges: intercepting changes in the column order applied by a user ( and programmatically setting the sort order for columns in a Rich Table ( As in these cases, the solution turns out to be fairly simple.


Changes applied at run time to the UI components in an ADF Faces page based on manipulations recorded through Change Persistence are applied through the ChangeManager class. In the same way ADF uses the ChangeManager to apply these changes read from MDS, we can also leverage the ChangeManager to apply our own changes. The article on intercepting column repositioning provided insight in the nature of the change: the repositioning of a column is recorded and applied as a change of type AttributeComponentChange. This class has a constructor that takes two arguments: the name of the attribute – displayIndex in this case – and the value of the attribute – an int specifying the new position of the column. The change can be applied to the RichColumn component using the addComponentChange method on the ChangeManager. This method takes three arguments: the current facesContext, the RichColumn on which to apply the change and the AttributeComponentChange object.

With this information, we can create the following code that complete reverses the initial ordering of columns in a table:

The method reorganizeColumnsInTable is invoked from a button in the page:



and results in the table being refreshed like this:


About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.

1 Comment

  1. Joe Ssemwogerere on

    Is it possible to reorder the columns before Restore View phase i.e. without using a button. I would like to be able to read user preferences from the database and use them as a basis for the ordering so that the first time the table is rendered, the column ordering is according to each user’s preferences.