예제 #1
0
  protected void exportRow(DataTable table, Writer writer, int rowIndex) throws IOException {
    String var = table.getVar().toLowerCase();
    table.setRowIndex(rowIndex);

    if (!table.isRowAvailable()) {
      return;
    }

    writer.write("\t<" + var + ">\n");
    exportCells(table, writer);
    writer.write("\t</" + var + ">\n");
  }
예제 #2
0
  public void encode(FacesContext context, DataTableRenderer renderer, DataTable table)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    String clientId = table.getClientId(context);
    String[] cellInfo = params.get(clientId + "_cellInfo").split(",");
    int rowIndex = Integer.parseInt(cellInfo[0]);
    int cellIndex = Integer.parseInt(cellInfo[1]);
    int i = -1;
    UIColumn column = null;
    for (UIColumn col : table.getColumns()) {
      if (col.isRendered()) {
        i++;

        if (i == cellIndex) {
          column = col;
          break;
        }
      }
    }

    table.setRowIndex(rowIndex);

    if (column.isDynamic()) {
      DynamicColumn dynamicColumn = (DynamicColumn) column;
      dynamicColumn.applyStatelessModel();
    }

    if (table.isCellEditEscapeRequest(context)) {
      column.getCellEditor().getFacet("input").encodeAll(context);
    } else {
      column.getCellEditor().getFacet("output").encodeAll(context);
    }

    if (column.isDynamic()) {
      ((DynamicColumn) column).cleanStatelessModel();
    }
  }
예제 #3
0
  @Override
  public void export(
      FacesContext context,
      DataTable table,
      String filename,
      boolean pageOnly,
      boolean selectionOnly,
      String encodingType,
      MethodExpression preProcessor,
      MethodExpression postProcessor)
      throws IOException {
    ExternalContext externalContext = context.getExternalContext();
    configureResponse(externalContext, filename);
    OutputStream os = externalContext.getResponseOutputStream();
    OutputStreamWriter osw = new OutputStreamWriter(os, encodingType);
    PrintWriter writer = new PrintWriter(osw);

    writer.write("<?xml version=\"1.0\"?>\n");
    writer.write("<" + table.getId() + ">\n");

    if (pageOnly) {
      exportPageOnly(table, writer);
    } else if (selectionOnly) {
      exportSelectionOnly(context, table, writer);
    } else {
      exportAll(table, writer);
    }

    writer.write("</" + table.getId() + ">");

    table.setRowIndex(-1);

    writer.flush();
    writer.close();

    externalContext.responseFlushBuffer();
  }