ADF 11g: Programmatically repositioning columns in a Rich Table

Lucas Jellema 1

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:


One thought on “ADF 11g: Programmatically repositioning columns in a Rich Table

  1. 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.

Comments are closed.

Next Post

Training iOS 5 applicatieontwikkeling voor iPhone en iPad

Van 5 tot en met 7 september geeft AMIS de training iOS5 applicatieontwikkeling. Leer in drie dagen zelf apps voor iPhone en iPad ontwikkelen. Schrijf je in via deze link: Related posts: OOW 2009: Castle in the Clouds: SaaS-Enabling Oracle ADF Faces Applications Live update of Resource Bundle from […]
%d bloggers like this: