protected static final String ICON_ORDER_DOWN = "order_down.gif";
protected static final String ICON_ORDER_UNKNOWN = "order.gif";
public void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws FormatterException {
tableHandler = (TableHandler) getParameter("tableHandler");
Table table = tableHandler.getTable();
if (table == null) {
renderFragment("notable");
return;
}
// Table start.
setTableAttributes(tableHandler);
renderFragment("tablestart");
setTableAttributes(tableHandler);
renderFragment("tablestarthead");
setTableAttributes(tableHandler);
renderFragment("tablestartcontents");
setTableAttributes(tableHandler);
renderFragment("tablestartcompleted");
renderFragment("outputtableend");
renderFragment("tableoutput");
// Table header at top.
if (table.getHeaderPosition().equals("top")) {
renderTableHeader(tableHandler);
}
// Table empty
if (table.getRowCount() == 0) {
renderFragment("tableempty");
}
// Body start.
else {
setTableAttributes(tableHandler);
renderFragment("bodystart");
// Current page rows.
int currentPage = table.getCurrentPage() - 1;
int pageSize = table.getMaxRowsPerPage();
int currentPageBegin = currentPage * pageSize;
for (int i=currentPageBegin; i < currentPageBegin + pageSize && i < table.getRowCount(); i++) {
// Row start.
setTableAttributes(tableHandler);
setAttribute("rowindex", i);
renderFragment("rowstart");
// Row value at column.
for (int j = 0; j < table.getColumnCount(); j++) {
TableColumn column = table.getColumn(j);
setTableAttributes(tableHandler);
setColumnAttributes(column, j);
setAttribute("rowindex", i);
setAttribute("rowvalue", formatCellValue(table, i, j));
setAttribute("columnhtmlvalue", formatHtmlCellValue(table, column, i,j));
renderFragment("rowcolumn");
}
// Row end.
setTableAttributes(tableHandler);
setAttribute("rowindex", i);
renderFragment("rowend");
}
// Body end.
setTableAttributes(tableHandler);
renderFragment("bodyend");
// Table header at bottom.
if (table.getHeaderPosition().equals("bottom")) {
renderTableHeader(tableHandler);
}
}
// Table end.
setTableAttributes(tableHandler);