Intercept Hide/Show column event



When we wrap a rich table in a panelcollection component, we get some interesting additional functionality. This includes the ability for the end user to hide and display columns. It may be useful to intercept that column hide/show event – for example to influence the query that is executed to retrieve the data for the table.=

There is no column property hideAndShow Listener, nor is there a special listener on the panelCollection component. After a little trial and error, I found out that the column show/hide event can be intercepted using an attributeChangeListener on the column component:

        <af:panelCollection id="empTablePanelCollection"
          <af:table value="#{bindings.emps.collectionModel}" var="row"   ...>
            <af:column sortProperty="job" sortable="true" id="colJob"
                       ... &gt;

The bean method is called with the attribute change event as parameter. From it, we can extract the component and attribute that were effected as well as the old and new value of the attribute.

package nl.amis.view;

import org.apache.myfaces.trinidad.event.AttributeChangeEvent;

public class TableListener {

    public void attributeChangeListener(AttributeChangeEvent attributeChangeEvent) {
        System.out.println(attributeChangeEvent.getNewValue() +&quot; old value &quot;+ attributeChangeEvent.getOldValue());

The debugoutput in the console:

true old value false

In later articles we will use this approach to set the values of bind parameters depending on columjns being hidden or shown.


About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director for Fusion Middleware. Consultant, trainer and instructor on diverse areas including Oracle Database (SQL & PLSQL), Service Oriented Architecture, BPM, ADF, Java in various shapes and forms and many other things. Author of the Oracle Press book: Oracle SOA Suite 11g Handbook. Frequent presenter on conferences such as JavaOne, Oracle OpenWorld, ODTUG Kaleidoscope, Devoxx and OBUG. Presenter for Oracle University Celebrity specials.

Comments are closed.