예제 #1
0
  /** Render column headers either in single row or nested if a columnGroup is defined */
  protected void encodeThead(FacesContext context, DataTable table) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    ColumnGroup group = table.getColumnGroup("header");

    writer.startElement("thead", null);
    writer.writeAttribute("id", table.getClientId(context) + "_head", null);

    if (group != null && group.isRendered()) {

      for (UIComponent child : group.getChildren()) {
        if (child.isRendered() && child instanceof Row) {
          Row headerRow = (Row) child;

          writer.startElement("tr", null);

          for (UIComponent headerRowChild : headerRow.getChildren()) {
            if (headerRowChild.isRendered() && headerRowChild instanceof Column) {
              encodeColumnHeader(context, table, (Column) headerRowChild);
            }
          }

          writer.endElement("tr");
        }
      }

    } else {
      writer.startElement("tr", null);
      writer.writeAttribute("role", "row", null);

      for (UIColumn column : table.getColumns()) {
        if (column instanceof Column) {
          encodeColumnHeader(context, table, column);
        } else if (column instanceof DynamicColumn) {
          DynamicColumn dynamicColumn = (DynamicColumn) column;
          dynamicColumn.applyModel();

          encodeColumnHeader(context, table, dynamicColumn);
        }
      }

      writer.endElement("tr");
    }

    encodeFrozenRows(context, table);

    writer.endElement("thead");
  }
예제 #2
0
  protected void encodeTFoot(FacesContext context, DataTable table) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    ColumnGroup group = table.getColumnGroup("footer");

    writer.startElement("tfoot", null);

    if (group != null && group.isRendered()) {

      for (UIComponent child : group.getChildren()) {
        if (child.isRendered() && child instanceof Row) {
          Row footerRow = (Row) child;

          writer.startElement("tr", null);

          for (UIComponent footerRowChild : footerRow.getChildren()) {
            if (footerRowChild.isRendered() && footerRowChild instanceof Column) {
              encodeColumnFooter(context, table, (Column) footerRowChild);
            }
          }

          writer.endElement("tr");
        }
      }

    } else if (table.hasFooterColumn()) {
      writer.startElement("tr", null);

      for (UIColumn column : table.getColumns()) {
        if (column instanceof Column) {
          encodeColumnFooter(context, table, column);
        } else if (column instanceof DynamicColumn) {
          DynamicColumn dynamicColumn = (DynamicColumn) column;
          dynamicColumn.applyModel();

          encodeColumnFooter(context, table, dynamicColumn);
        }
      }

      writer.endElement("tr");
    }

    writer.endElement("tfoot");
  }