|
Hello, I think I have everything set up correctly now to sort my Data Table, but clicking on a header column still does not call the "sort()" method. In fact, nothing happens. The data table comes up OK with a down arrow in the person column so I think I'm reeeeealy close. Here's my table data definition and one of the columns: <t:dataTable value ="#{TD.updates}" width="100%" var="update" sortColumn="#{TD.sort}" sortAscending="#{TD.ascending}" preserveDataModel="true" preserveSort="true"> <t:column> <f:facet name="header"> <t:commandSortHeader columnName="Person" arrow = "true" > <h:outputText value="#{msgs.PersonName}" /> </t:commandSortHeader> </f:facet> <h:outputText value="#{update.personName}" /> </t:column> The actual column in the database is personName. But, when I click on the "Person" header in the data table ("Person" comes from msgs.PersonName), nothing happens. The sort() method doesn't get called in the "TD" class. I've tried setting the columnName to personName (to match the database name), but that doesn't work either. I have code in the TD.sort() method that prints a message if it runs. When the JSP initially comes up, the method runs to sort the list initially. My Sort method looks like this: protected void sort(final String column, final boolean ascending) { Comparator comparator = new Comparator() { public int compare(Object o1, Object o2) { // personDataItem is a POJO item from the ArrayList Persons PersonDataItem c1 = (PersonDataItem)o1; PersonDataItem c2 = (PersonDataItem)o2; if (column == null) { return 0; } if (column.equals("Account")) { return ascending ? c1.getPersonName().compareTo(c2.getPersonName()) : c2.getPersonName().compareTo(c1.getPersonName()); } else return 0; } }; Collections.sort(_persons, comparator); } Note: _persons is set equal to the ArrayList in the getPersons() setup call. What am I missing to get the header to actually call the sort() method? Thanks lots in advance. Mike |
- Getting sorting to work in data table -- header click does not ... Mike

