Package com.lassitercg.faces.components.util

Examples of com.lassitercg.faces.components.util.VarBuilder


   * @param writer
   * @param sheet
   * @throws IOException
   */
  protected void encodeColHeaders(FacesContext context, Sheet sheet, WidgetBuilder wb) throws IOException {
    VarBuilder vb = new VarBuilder(null, false);
    for (Column column : sheet.getColumns()) {
      if (!column.isRendered())
        continue;
      vb.appendArrayValue(column.getHeaderText(), true);
    }
    wb.nativeAttr("colHeaders", vb.closeVar().toString());
  }
View Full Code Here


   * @param writer
   * @param sheet
   * @throws IOException
   */
  protected void encodeColOptions(FacesContext context, Sheet sheet, WidgetBuilder wb) throws IOException {
    VarBuilder vb = new VarBuilder(null, false);
    for (Column column : sheet.getColumns()) {
      if (!column.isRendered())
        continue;

      VarBuilder options = new VarBuilder(null, true);
      options.appendProperty("type", column.getColType(), true);
      Integer width = column.getColWidth();
      if (width != null)
        options.appendProperty("width", width.toString(), false);
      if (column.isReadonly())
        options.appendProperty("readOnly", "true", false);
      vb.appendArrayValue(options.closeVar().toString(), false);
    }
    wb.nativeAttr("columns", vb.closeVar().toString());
  }
View Full Code Here

   * @param jsDataVar
   * @throws IOException
   */
  protected void encodeData(FacesContext context, Sheet sheet, WidgetBuilder wb) throws IOException {

    VarBuilder vbData = new VarBuilder(null, false);
    VarBuilder vbStyle = new VarBuilder(null, true);
    VarBuilder vbRowStyle = new VarBuilder(null, false);
    VarBuilder vbReadOnly = new VarBuilder(null, true);

    List<Object> values = sheet.getSortedValues();
    int row = 0;
    for (Object value : values) {
      sheet.setRowIndex(context, row);
      encodeRow(context, vbData, vbRowStyle, vbStyle, vbReadOnly, sheet, value, row);
      row++;
    }
    sheet.setRowIndex(context, -1);
    wb.nativeAttr("data", vbData.closeVar().toString());
    wb.nativeAttr("styles", vbStyle.closeVar().toString());
    wb.nativeAttr("rowStyles", vbRowStyle.closeVar().toString());
    wb.nativeAttr("readOnly", vbReadOnly.closeVar().toString());
  }
View Full Code Here

      vbRowStyle.appendArrayValue("null", false);
    else
      vbRowStyle.appendArrayValue(rowStyleClass, true);

    // data is array of array of data
    VarBuilder vbRow = new VarBuilder(null, false);
    int renderCol = 0;
    for (int col = 0; col < sheet.getColumns().size(); col++) {
      final Column column = sheet.getColumns().get(col);
      if (!column.isRendered())
        continue;

      // render data value
      String value = sheet.getRenderValueForCell(context, sheet.getRowKeyValue(context), col);
      vbRow.appendArrayValue(value, true);

      // custom style
      String styleClass = column.getStyleClass();
      if (styleClass != null) {
        vbStyle.appendRowColProperty(rowIndex, renderCol, styleClass, true);
      }

      // read only per cell
      boolean readOnly = column.isReadonlyCell();
      if (readOnly)
        vbReadOnly.appendRowColProperty(rowIndex, renderCol, "true", true);
      renderCol++;
    }
    // close row and append to vbData
    vbData.appendArrayValue(vbRow.closeVar().toString(), false);
  }
View Full Code Here

   * @param sheet
   * @param jsFilterVar
   * @throws IOException
   */
  protected void encodeFilterVar(FacesContext context, Sheet sheet, WidgetBuilder wb) throws IOException {
    VarBuilder vb = new VarBuilder(null, false);

    for (Column column : sheet.getColumns()) {
      if (!column.isRendered())
        continue;

      if (column.getValueExpression("filterBy") == null) {
        vb.appendArrayValue("false", true);
        continue;
      }

      Collection<SelectItem> options = column.getFilterOptions();
      if (options == null)
        vb.appendArrayValue("true", true);
      else {
        VarBuilder vbOptions = new VarBuilder(null, false);
        for (SelectItem item : options) {
          vbOptions.appendArrayValue("{ label: \"" + item.getLabel() + "\", value: \"" + item.getValue()
              + "\"}",
              false);
        }
        vb.appendArrayValue(vbOptions.closeVar().toString(), false);
      }

    }
    wb.nativeAttr("filters", vb.closeVar().toString());
  }
View Full Code Here

   * @param sheet
   * @param jsFilterVar
   * @throws IOException
   */
  protected void encodeSortVar(FacesContext context, Sheet sheet, WidgetBuilder wb) throws IOException {
    VarBuilder vb = new VarBuilder(null, false);

    for (Column column : sheet.getColumns()) {
      if (!column.isRendered())
        continue;

      if (column.getValueExpression("sortBy") == null)
        vb.appendArrayValue("false", false);
      else
        vb.appendArrayValue("true", false);
    }
    wb.nativeAttr("sortable", vb.closeVar().toString());
  }
View Full Code Here

   * @param sheet
   * @param badDataVar
   * @return
   */
  public String getBadDataValue() {
    VarBuilder vb = new VarBuilder(null, true);
    for (BadUpdate badUpdate : getBadUpdates()) {
      final Object rowKey = badUpdate.getBadRowKey();
      final int col = getRenderIndexFromRealIdx(badUpdate.getBadColIndex());
      RowMap map = rowMap.get(rowKey);
      System.out.println("RowMap is " + map.sortedIndex + " for key " + rowKey);
      vb.appendRowColProperty(map.sortedIndex, col, badUpdate.getBadMessage().replace("'", "&apos;"), true);
    }
    return vb.closeVar().toString();
  }
View Full Code Here

    for (Object rowKey : dirtyRows) {
      RowMap map = this.rowMap.get(rowKey);
      setRowIndex(context, map.sortedIndex);
      // data is array of array of data
      VarBuilder vbRow = new VarBuilder(null, false);
      for (int col = 0; col < getColumns().size(); col++) {
        final Column column = getColumns().get(col);
        if (!column.isRendered())
          continue;

        // render data value
        String value = getRenderValueForCell(context, rowKey, col);
        vbRow.appendArrayValue(value, true);
      }
      eval.append(jsVar);
      eval.append(".cfg.data[");
      eval.append(Integer.toString(map.sortedIndex));
      eval.append("]=");
      eval.append(vbRow.closeVar().toString());
      eval.append(";");
    }
    eval.append(jsVar);
    eval.append(".ht.render();");
    RequestContext.getCurrentInstance().getScriptsToExecute().add(eval.toString());
View Full Code Here

TOP

Related Classes of com.lassitercg.faces.components.util.VarBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.