else if(value instanceof ListDataModel)
list = (List) ((ListDataModel) value).getWrappedData();
else
throw new FacesException("Data type should be java.util.List or javax.faces.model.ListDataModel instance to be sortable.");
ChainedBeanPropertyComparator chainedComparator = new ChainedBeanPropertyComparator();
for(SortMeta meta : sortMeta) {
BeanPropertyComparator comparator;
UIColumn sortColumn = meta.getColumn();
ValueExpression sortByVE;
ValueExpression columnSortByVE = sortColumn.getValueExpression("sortBy");
if(sortColumn.isDynamic()) {
((DynamicColumn) sortColumn).applyStatelessModel();
Object sortByProperty = sortColumn.getSortBy();
if(sortByProperty == null) {
sortByVE = columnSortByVE;
comparator = new DynamicChainedPropertyComparator((DynamicColumn) sortColumn, sortByVE, table.getVar(), meta.getSortOrder(), sortColumn.getSortFunction(), caseSensitiveSort, locale);
}
else {
sortByVE = createValueExpression(context, table.getVar(), sortByProperty);
comparator = new BeanPropertyComparator(sortByVE, table.getVar(), meta.getSortOrder(), sortColumn.getSortFunction(), caseSensitiveSort, locale);
}
}
else {
sortByVE = (columnSortByVE != null) ? columnSortByVE : createValueExpression(context, table.getVar(), sortColumn.getSortBy());
comparator = new BeanPropertyComparator(sortByVE, table.getVar(), meta.getSortOrder(), sortColumn.getSortFunction(), caseSensitiveSort, locale);
}
chainedComparator.addComparator(comparator);
}
Collections.sort(list, chainedComparator);
}