Beispiel #1
0
  private void renderToHandler(OutputTypeHandler outputHandler, UIData uiData, FacesContext fc) {

    try {
      int rowIndex = 0;
      int numberOfRowsToDisplay = 0;
      if (!isIgnorePagination()) {
        rowIndex = uiData.getFirst();
        numberOfRowsToDisplay = uiData.getRows();
        first = rowIndex;
        rows = numberOfRowsToDisplay;
      }

      int countOfRowsDisplayed = 0;
      uiData.setRowIndex(rowIndex);
      String[] includeColumnsArray = null;
      String includeColumns = getIncludeColumns();
      if (includeColumns != null) includeColumnsArray = includeColumns.split(",");
      List columns = getRenderedChildColumnsList(uiData);
      // System.out.println("DataExporter.renderToHandler()  columns.size: " + columns.size());

      // write header
      // System.out.println("DataExporter.renderToHandler()  HEADERS");
      processAllColumns(fc, outputHandler, columns, includeColumnsArray, -1, false);

      // System.out.println("DataExporter.renderToHandler()  ROWS");
      while (uiData.isRowAvailable()) {
        if (numberOfRowsToDisplay > 0 && countOfRowsDisplayed >= numberOfRowsToDisplay) {
          break;
        }

        // render the child columns; each one in a td
        processAllColumns(
            fc, outputHandler, columns, includeColumnsArray, countOfRowsDisplayed, false);

        // keep track of rows displayed
        countOfRowsDisplayed++;
        // maintain the row index property on the underlying UIData
        // component
        rowIndex++;
        uiData.setRowIndex(rowIndex);
      }
      // reset the underlying UIData component
      uiData.setRowIndex(-1);

      // write footer
      // System.out.println("DataExporter.renderToHandler()  FOOTERS");
      processAllColumns(
          fc, outputHandler, columns, includeColumnsArray, countOfRowsDisplayed, true);

      outputHandler.flushFile();
    } catch (Exception e) {
      log.error("renderToHandler()", e);
    }
  }