Package org.apache.myfaces.tobago.component

Examples of org.apache.myfaces.tobago.component.UISheet



  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {

    UISheet sheet = (UISheet) uiComponent;

    Style style = new Style(facesContext, sheet);

    final String sheetId = sheet.getClientId(facesContext);

    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    // Outer sheet div
    writer.startElement(HtmlElements.DIV, sheet);
    writer.writeIdAttribute(sheetId);
    final String css = Classes.create(sheet).getStringValue() + " " + Classes.create(sheet, "outer").getStringValue();
    // todo: please remove the "outer" sub in the future,
    // todo: it was renamed from tobago-sheet-outer to tobago-sheet because of naming conventions.
    writer.writeClassAttribute(css);
    writer.writeStyleAttribute(style);
    UICommand clickAction = null;
    UICommand dblClickAction = null;
    int columnSelectorIndex = -1;
    int i = 0;
    for (UIComponent child : (List<UIComponent>) sheet.getChildren()) {
      if (child instanceof UIColumnEvent) {
        UIColumnEvent columnEvent = (UIColumnEvent) child;
        if (columnEvent.isRendered()) {
          UIComponent selectionChild = (UIComponent) child.getChildren().get(0);
          if (selectionChild != null && selectionChild instanceof UICommand && selectionChild.isRendered()) {
            UICommand action = (UICommand) selectionChild;
            if ("click".equals(columnEvent.getEvent())) {
              clickAction = action;
            }
            if ("dblclick".equals(columnEvent.getEvent())) {
              dblClickAction = action;
            }
          }
        }
      } else if (child instanceof UIColumnSelector) {
        columnSelectorIndex = i;
      }
      i++;
    }

    renderSheet(facesContext, sheet, (clickAction != null || dblClickAction != null), style);

    writer.endElement(HtmlElements.DIV);
    // TODO check ajax id
    if (!(FacesContextUtils.isAjax(facesContext)
        && sheetId.equals(FacesContextUtils.getAjaxComponentId(facesContext)))) {

      Integer frequency = null;
      UIComponent facetReload = sheet.getFacet(Facets.RELOAD);
      if (facetReload != null && facetReload instanceof UIReload && facetReload.isRendered()) {
        UIReload update = (UIReload) facetReload;
        frequency = update.getFrequency();
      }
      final String[] cmds = {
          "new Tobago.Sheet('" + sheetId
              + "', " + sheet.getFirst()
              + ", '" + sheet.getSelectable()
              + "', " + columnSelectorIndex
              + ", " + frequency
              + ", " + (clickAction != null ? HtmlRendererUtils.getJavascriptString(clickAction.getId()) : null)
              + ", " + HtmlRendererUtils.getRenderedPartiallyJavascriptArray(facesContext, clickAction)
              + ", " + (dblClickAction != null ? HtmlRendererUtils.getJavascriptString(dblClickAction.getId()) : null)
View Full Code Here


  @Override
  public void decode(FacesContext facesContext, UIComponent component) {
    super.decode(facesContext, component);

    UISheet sheet = (UISheet) component;

    String key = sheet.getClientId(facesContext) + WIDTHS_POSTFIX;

    Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
    if (requestParameterMap.containsKey(key)) {
      String widths = (String) requestParameterMap.get(key);
      if (widths.trim().length() > 0) {
        sheet.getAttributes().put(Attributes.WIDTH_LIST_STRING, widths);
      }
    }

    key = sheet.getClientId(facesContext) + SELECTED_POSTFIX;
    if (requestParameterMap.containsKey(key)) {
      String selected = (String) requestParameterMap.get(key);
      if (LOG.isDebugEnabled()) {
        LOG.debug("selected = " + selected);
      }
      List<Integer> selectedRows;
      try {
        selectedRows = StringUtils.parseIntegerList(selected);
      } catch (NumberFormatException e) {
        LOG.warn(selected, e);
        selectedRows = Collections.emptyList();
      }

      sheet.getAttributes().put(Attributes.SELECTED_LIST_STRING, selectedRows);
    }

    key = sheet.getClientId(facesContext) + SCROLL_POSTFIX;
    String value = (String) requestParameterMap.get(key);
    if (value != null) {
      Integer[] scrollPosition = SheetState.parseScrollPosition(value);
      if (scrollPosition != null) {
        //noinspection unchecked
        sheet.getAttributes().put(Attributes.SCROLL_POSITION, scrollPosition);
      }
    }

    RenderUtils.decodedStateOfTreeData(facesContext, sheet);
  }
View Full Code Here

    return getBorderLeft(facesContext, data).add(getBorderRight(facesContext, data));
  }

  @Override
  public Measure getPreferredHeight(FacesContext facesContext, Configurable component) {
    final UISheet sheet = (UISheet) component;
    Measure headerHeight = getHeaderHeight(facesContext, sheet);
    Measure rowHeight = getRowHeight(facesContext, sheet);
    Measure footerHeight = getFooterHeight(facesContext, sheet);
    int rows = sheet.getRows();
    if (rows == 0) {
      rows = sheet.getRowCount();
    }
    if (rows == -1) {
      rows = 10; // estimating something to get a valid value...
    }
View Full Code Here

    UIComponent component = event.getComponent();
    while (!(component instanceof UISheet)) {
      component = component.getParent();
    }

    final UISheet sheet = (UISheet) component;
    entry = (Entry) sheet.getRowData();
    LOG.info("entry = \"" + entry.getColumn1() + "\"");
  }
View Full Code Here

    UIComponent component = event.getComponent();
    while (!(component instanceof UISheet)) {
      component = component.getParent();
    }

    final UISheet sheet = (UISheet) component;
    entry = (Entry) sheet.getRowData();
    LOG.info("entry = \"" + entry.getColumn1() + "\"");
  }
View Full Code Here

  }

  @Override
  public void encodeEnd(final FacesContext facesContext, final UIComponent uiComponent) throws IOException {

    final UISheet sheet = (UISheet) uiComponent;

    final Style style = new Style(facesContext, sheet);

    final String sheetId = sheet.getClientId(facesContext);

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    // Outer sheet div
    writer.startElement(HtmlElements.DIV, sheet);
    writer.writeIdAttribute(sheetId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, sheet);
    writer.writeClassAttribute(Classes.create(sheet));
    writer.writeStyleAttribute(style);
    final UIComponent facetReload = sheet.getFacet(Facets.RELOAD);
    if (facetReload != null && facetReload instanceof UIReload && facetReload.isRendered()) {
      final UIReload update = (UIReload) facetReload;
      writer.writeAttribute(DataAttributes.RELOAD, update.getFrequency());
    }

    writer.writeAttribute(DataAttributes.PARTIALLY,
        HtmlRendererUtils.getRenderedPartiallyJavascriptArray(facesContext, sheet, sheet), false);
    writer.writeAttribute(DataAttributes.SELECTION_MODE, sheet.getSelectable(), false);
    writer.writeAttribute(DataAttributes.FIRST, Integer.toString(sheet.getFirst()), false);

    final boolean rowAction = HtmlRendererUtils.renderSheetCommands(sheet, facesContext, writer);

    renderSheet(facesContext, sheet, rowAction, style);
View Full Code Here

  @Override
  public void decode(final FacesContext facesContext, final UIComponent component) {
    super.decode(facesContext, component);

    final UISheet sheet = (UISheet) component;

    String key = sheet.getClientId(facesContext) + WIDTHS_POSTFIX;

    final Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
    if (requestParameterMap.containsKey(key)) {
      final String widths = (String) requestParameterMap.get(key);
      if (widths.trim().length() > 0) {
        sheet.getAttributes().put(Attributes.WIDTH_LIST_STRING, widths);
      }
    }

    key = sheet.getClientId(facesContext) + SELECTED_POSTFIX;
    if (requestParameterMap.containsKey(key)) {
      final String selected = (String) requestParameterMap.get(key);
      if (LOG.isDebugEnabled()) {
        LOG.debug("selected = " + selected);
      }
      List<Integer> selectedRows;
      try {
        selectedRows = StringUtils.parseIntegerList(selected);
      } catch (final NumberFormatException e) {
        LOG.warn(selected, e);
        selectedRows = Collections.emptyList();
      }

      sheet.getAttributes().put(Attributes.SELECTED_LIST_STRING, selectedRows);
    }

    RenderUtils.decodeScrollPosition(facesContext, sheet);
    RenderUtils.decodedStateOfTreeData(facesContext, sheet);
  }
View Full Code Here

    return getBorderLeft(facesContext, data).add(getBorderRight(facesContext, data));
  }

  @Override
  public Measure getPreferredHeight(final FacesContext facesContext, final Configurable component) {
    final UISheet sheet = (UISheet) component;
    final Measure headerHeight = getHeaderHeight(facesContext, sheet);
    final Measure rowHeight = getRowHeight(facesContext, sheet);
    final Measure footerHeight = getFooterHeight(facesContext, sheet);
    int rows = sheet.getRows();
    if (rows == 0) {
      rows = sheet.getRowCount();
    }
    if (rows == -1) {
      rows = 10; // estimating something to get a valid value...
    }
View Full Code Here

    return true;
  }

  @Override
  public void prepareRendersChildren(final FacesContext facesContext, final UIComponent component) throws IOException {
    final UISheet sheet = (UISheet) component;
    for (final UIColumn column : sheet.getRenderedColumns()) {
      if (column instanceof AbstractUIColumnNode) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("TODO: AbstractUIColumnNode are not prepared.");
        }
        // TBD: when the column should be prepared for rendering, I think we need to
View Full Code Here

    LOG.info("click the action listener");
    lastAction = actionEvent.getComponent().getId();
  }

  public void resetColumnWidths(final ActionEvent event) {
    final UISheet sheet = (UISheet) event.getComponent().findComponent("sheet");
    if (sheet != null) {
      sheet.resetColumnWidths();
    } else {
      LOG.warn("Didn't find sheet component!");
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.component.UISheet

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.