Hackers and Painters
Labels: Technical
Two roads diverged in a wood, and I - I took the one less travelled by, And that has made all the difference -Robert Frost
Labels: Technical
<h:datatable id="addressTableHeader" border="0" cellpadding="0" cellspacing="0">
<h:column>
<f:facet name="header">
<h:outputtext value="Post Code">
</f:facet>
</h:column>
<h:column>
<f:facet name="header">
<h:outputtext value="Street">
</f:facet>
</h:column>
</h:dataTable>
<h:datatable id="addressTableBody" var="tableData" value="#{Bean.addressList}">
<h:column>
<h:outputtext value="#{tabledata.postcode}">
</h:column>
<h:column>
<h:outputtext value="#{tabledata.street}">
</h:column>
</h:dataTable>
getAddressList()which wraps an ArrayList inside a ListDataModel and returns it.
<h:datatable id="addressTableHeader" border="0" cellpadding="0" cellspacing="0">
<h:column>
<f:facet name="header">
<a4j:commandlink action="#{Bean.postcodeSort}" ajaxsingle="true" rerender="addressTableBody" immediate="true">
<h:outputtext value="Post Code" styleclass="tariffpopupsearchheading">
</a4j:commandLink>
</f:facet>
</h:column>
<h:column>
<f:facet name="header">
<a4j:commandlink action="#{Bean.streetSort}" ajaxsingle="true" rerender="addressTableBody" immediate="true">
<h:outputtext value="Street" styleclass="tariffpopupsearchheading">
</a4j:commandLink>
</f:facet>
</h:column>
</h:dataTable>
postcodeSort()and
streetSort()are added to the Bean, which help to set the sorting criteria on click . The Bean's
getAddresslist()method is modified to pass the appropriate Comparator.
Labels: Technical Java