Hi All,
I'm having troubles with the sort of a sheet in Tobago.
But the info in the sheet doesn't get sorted by the column selected.
What can be the problem?
Any suggestion?
In my JSP:
<tc:sheet ........... . . . . .
. . . . . . . .
sortActionListener="#{accessBean.sheetSorter}">
<tc:column label="#{overviewBundle.userLoginUser}"
id="userName" sortable="true" align="center">
In my Class:
public void sheetSorter(ActionEvent event) {
if (event instanceof SortActionEvent) {
SortActionEvent sortEvent = (SortActionEvent) event;
UIData sheet = sortEvent.getSheet();
SheetState sheetState
=
sheet.getSheetState(FacesContext.getCurrentInstance());
String columnId = sheetState.getSortedColumnId();
List<UserLogin> list = (List<UserLogin>)
sheet.getValue();
Comparator<UserLogin> comparator = null;
if ("userName".equals(columnId)) {
comparator = new Comparator<UserLogin>() {
public int compare(UserLogin o1, UserLogin
o2) {
return
o1.getUserName().compareTo(o2.getUserName());
}
};
}
Collections.sort(list, comparator);
for (Iterator iter = list.iterator(); iter.hasNext();)
{
System.out.println(iter.getClass().getName().toString());
}
if (!sheetState.isAscending()) {
Collections.reverse(list);
}
}
Regards