コード例 #1
0
  protected void renderTableHeader(TableHandler tableHandler) {
    // Table header.
    Table table = tableHandler.getTable();
    setTableAttributes(tableHandler);
    renderFragment("headerstart");

    // Header columns.
    for (int j = 0; j < table.getColumnCount(); j++) {
      TableColumn column = table.getColumn(j);
      setTableAttributes(tableHandler);
      setColumnAttributes(column, j);
      Integer selectedIdx = tableHandler.getSelectedColumnIndex();
      if (selectedIdx != null && selectedIdx.intValue() == j) renderFragment("headerselected");
      else renderFragment("headercolumn");
    }

    // Header end.
    setTableAttributes(tableHandler);
    renderFragment("headerend");
  }
コード例 #2
0
  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");
  }