Object value = data.getValue();
if (value instanceof DataModel) {
value = ((DataModel) value).getWrappedData();
}
SheetState sheetState = data.getSheetState(facesContext);
Comparator actualComparator = null;
if (value instanceof List || value instanceof Object[]) {
String sortProperty;
try {
UIComponent child = getFirstSortableChild(column.getChildren());
if (child != null) {
ValueBinding valueBinding = child.getValueBinding("value");
String var = data.getVar();
if (valueBinding != null) {
if (isSimpleProperty(valueBinding.getExpressionString())) {
String expressionString = valueBinding.getExpressionString();
if (expressionString.startsWith("#{")
&& expressionString.endsWith("}")) {
expressionString =
expressionString.substring(2,
expressionString.length() - 1);
}
sortProperty = expressionString.substring(var.length() + 1);
actualComparator = new BeanComparator(
sortProperty, comparator, !sheetState.isAscending());
if (LOG.isDebugEnabled()) {
LOG.debug("Sort property is " + sortProperty);
}
} else {
actualComparator = new ValueBindingComparator(facesContext, var,
valueBinding, !sheetState.isAscending(), comparator);
}
}
} else {
LOG.error("No sortable component found!");