protected void setTableAttributes(TableHandler tableHandler) {
   Table table = tableHandler.getTable();
   setAttribute("currentpage", table.getCurrentPage());
   setAttribute("rowcount", table.getRowCount());
   setAttribute("maxrowspage", table.getMaxRowsPerPage());
   setAttribute("headerposition", table.getHeaderPosition());
   setAttribute(
       "htmlstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getHtmlStyle())));
   setAttribute(
       "rowevenstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowEvenStyle())));
   setAttribute(
       "rowoddstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowOddStyle())));
   setAttribute(
       "rowhoverstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowHoverStyle())));
   setAttribute(
       "htmlclass", StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getHtmlClass())));
   setAttribute(
       "rowevenclass",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowEventClass())));
   setAttribute(
       "rowoddclass",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowOddClass())));
   setAttribute(
       "rowhoverclass",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowHoverClass())));
   setAttribute("htmlstyleview", table.getHtmlStyle());
 }
  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);
    renderFragment("tableend");
  }