public void actionSortByColumn(CommandRequest request) throws Exception {
int tableColumnIdx = Integer.parseInt(request.getRequestObject().getParameter("columnindex"));
TableColumn tableColumn = getTable().getColumn(tableColumnIdx);
AbstractTableModel model = (AbstractTableModel) getTable().getModel();
ComparatorByCriteria comparator = model.getComparator();
if (comparator != null) {
String modelColumnIdx = Integer.toString(model.getColumnPosition(tableColumn.getPropertyId()));
int currentOrdering = ComparatorByCriteria.ORDER_ASCENDING;
if (comparator.existCriteria(modelColumnIdx)) currentOrdering = comparator.getSortCriteriaOrdering(modelColumnIdx);
if (currentOrdering == ComparatorByCriteria.ORDER_UNSPECIFIED) currentOrdering = ComparatorByCriteria.ORDER_ASCENDING;
else if (currentOrdering == ComparatorByCriteria.ORDER_ASCENDING) currentOrdering = ComparatorByCriteria.ORDER_DESCENDING;
else currentOrdering = ComparatorByCriteria.ORDER_ASCENDING;
comparator.removeAllSortCriteria();
comparator.addSortCriteria(modelColumnIdx, currentOrdering);
model.sort(comparator);
}
}