Posts

Showing posts from January 16, 2012

Easily disable sorting in PrimeFaces 3's DataTable

PrimeFaces provides a convenient and easy to use sorting facility for its DataTable . Together with Facelets, this facility allows us to create re-usable columns that are natural sortable by default. E.g.: <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" > <p:column headerText="#{headerText}" sortBy="#{value}"> <h:outputText id="#{id}" value="#{value}" /> </p:column> </ui:composition> Such a column can be used on a page inside a DataTable as follows: <my:sortableColumn id="foo" value="#{someBean.someValue}" /> The problem The above is only a simple example, and real-life usage can be more complex with e.g. default styles and cell editing capabilities added. With such complex tags, i...