Examples of UIMenuCommand


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

    int index = 0;
    for (final UIComponent child : tabGroup.getChildren()) {
      if (child instanceof UITab) {
        final UITab tab = (UITab) child;
        if (tab.isRendered()) {
          final UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, viewRoot.createUniqueId());
          entry.setTransient(true);
          entry.setOmit(true); // avoid submit
          final LabelWithAccessKey label = new LabelWithAccessKey(tab);
          entry.setLabel(label.getText());
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            ComponentUtils.putDataAttribute(entry, "tobago-index", index); // XXX todo, define a DataAttribute
          }
          menu.getChildren().add(entry);
        }
View Full Code Here

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

  private void createMenuItem(
      final FacesContext facesContext, final UIMenu menu, final String label, final Markup markup,
      final String sheetId) {
    final String id = markup.toString();
    final UIMenuCommand menuItem = (UIMenuCommand) CreateComponentUtils.createComponent(
        facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, id);
    menuItem.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", label));
    menuItem.setMarkup(markup);
    menuItem.setOmit(true);
    ComponentUtils.putDataAttributeWithPrefix(menuItem, DataAttributes.SHEET_ID, sheetId);
    menu.getChildren().add(menuItem);
  }
View Full Code Here

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

  private static final Logger LOG = LoggerFactory.getLogger(MenuCommandRenderer.class);

  @Override
  public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
    final UIMenuCommand menu = (UIMenuCommand) component;
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    final boolean disabled = menu.isDisabled();
    final boolean firstLevel = RendererTypes.MENU_BAR.equals(menu.getParent().getRendererType());
    final LabelWithAccessKey label = new LabelWithAccessKey(menu);

    if (menu.getFacet(Facets.CHECKBOX) != null) {
      // checkbox menu
      final UISelectBooleanCheckbox checkbox = (UISelectBooleanCheckbox) menu.getFacet(Facets.CHECKBOX);
      final boolean checked = ComponentUtils.getBooleanAttribute(checkbox, Attributes.VALUE);
      final String image = checked ? "image/MenuCheckmark.gif" : null;
      final String hiddenId = checkbox.getClientId(facesContext);
      final CommandMap map = new CommandMap(new Command());
      encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, "selectBoolean");
      encodeHidden(writer, hiddenId, checked);
    } else if (menu.getFacet(Facets.RADIO) != null) {
      // radio menu
      final String clientId = menu.getClientId(facesContext);
      final UISelectOne radio = (UISelectOne) menu.getFacet(Facets.RADIO);
      final String hiddenId = radio.getClientId(facesContext);
      for (final SelectItem item : SelectItemUtils.getItemIterator(facesContext, radio)) {
        final boolean checked = ObjectUtils.equals(item.getValue(), radio.getValue());
        final String image = checked ? "image/MenuRadioChecked.gif" : null;
        final String labelText = item.getLabel();
        label.reset();

        if (labelText != null) {
          if (labelText.indexOf(LabelWithAccessKey.INDICATOR) > -1) {
            label.setup(labelText);
          } else {
            label.setText(labelText);
          }
        } else {
          LOG.warn("Menu item has label=null where clientId=" + clientId);
        }
        final String formattedValue = RenderUtils.getFormattedValue(facesContext, radio, item.getValue());
        final CommandMap map = new CommandMap(
            new Command(clientId, null, null, null, null, null, null, null, null, null));
        encodeItem(facesContext, writer, null, label, map, disabled, firstLevel, image, formattedValue, "selectOne");
      }
      encodeHidden(writer, hiddenId, getCurrentValue(facesContext, radio));
    } else {
      // normal menu command
      final String image = menu.getImage();
      final CommandMap map = new CommandMap(new Command(facesContext, menu));
      encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, null);
    }
  }
View Full Code Here

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

  private void createMenuItem(
      final FacesContext facesContext, final UIMenu menu, final String label, final Markup markup,
      final String sheetId) {
    final String id = markup.toString();
    final UIMenuCommand menuItem = (UIMenuCommand) CreateComponentUtils.createComponent(
        facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, id);
    menuItem.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", label));
    menuItem.setMarkup(markup);
    menuItem.setOmit(true);
    ComponentUtils.putDataAttributeWithPrefix(menuItem, DataAttributes.SHEET_ID, sheetId);
    menu.getChildren().add(menuItem);
  }
View Full Code Here

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

  private static final Logger LOG = LoggerFactory.getLogger(MenuCommandRenderer.class);

  @Override
  public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
    final UIMenuCommand menu = (UIMenuCommand) component;
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    final boolean disabled = menu.isDisabled();
    final boolean firstLevel = RendererTypes.MENU_BAR.equals(menu.getParent().getRendererType());
    final LabelWithAccessKey label = new LabelWithAccessKey(menu);

    if (menu.getFacet(Facets.CHECKBOX) != null) {
      // checkbox menu
      final UISelectBooleanCheckbox checkbox = (UISelectBooleanCheckbox) menu.getFacet(Facets.CHECKBOX);
      final boolean checked = ComponentUtils.getBooleanAttribute(checkbox, Attributes.VALUE);
      final String image = checked ? "image/MenuCheckmark.gif" : null;
      final String hiddenId = checkbox.getClientId(facesContext);
      final CommandMap map = new CommandMap(new Command());
      encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, "selectBoolean");
      encodeHidden(writer, hiddenId, checked);
    } else if (menu.getFacet(Facets.RADIO) != null) {
      // radio menu
      final String clientId = menu.getClientId(facesContext);
      final UISelectOne radio = (UISelectOne) menu.getFacet(Facets.RADIO);
      final String hiddenId = radio.getClientId(facesContext);
      for (final SelectItem item : SelectItemUtils.getItemIterator(facesContext, radio)) {
        final boolean checked = item.getValue().equals(radio.getValue());
        final String image = checked ? "image/MenuRadioChecked.gif" : null;
        final String labelText = item.getLabel();
        label.reset();

        if (labelText != null) {
          if (labelText.indexOf(LabelWithAccessKey.INDICATOR) > -1) {
            label.setup(labelText);
          } else {
            label.setText(labelText);
          }
        } else {
          LOG.warn("Menu item has label=null where clientId=" + clientId);
        }
        final String formattedValue = RenderUtils.getFormattedValue(facesContext, radio, item.getValue());
        final CommandMap map = new CommandMap(
            new Command(clientId, null, null, null, null, null, null, null, null, null));
        encodeItem(facesContext, writer, null, label, map, disabled, firstLevel, image, formattedValue, "selectOne");
      }
      encodeHidden(writer, hiddenId, getCurrentValue(facesContext, radio));
    } else {
      // normal menu command
      final String image = menu.getImage();
      final CommandMap map = new CommandMap(new Command(facesContext, menu));
      encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, null);
    }
  }
View Full Code Here

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

  private void createMenuItem(
      final FacesContext facesContext, final UIMenu menu, final String label, final Markup markup,
      final String sheetId) {
    final String id = markup.toString();
    final UIMenuCommand menuItem = (UIMenuCommand) CreateComponentUtils.createComponent(
        facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, id);
    menuItem.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", label));
    menuItem.setMarkup(markup);
    menuItem.setOnclick("/**/"); // XXX avoid submit
    ComponentUtils.putDataAttributeWithPrefix(menuItem, DataAttributes.SHEET_ID, sheetId);
    menu.getChildren().add(menuItem);
  }
View Full Code Here

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

    int index = 0;
    for (final UIComponent child : tabGroup.getChildren()) {
      if (child instanceof UITab) {
        final UITab tab = (UITab) child;
        if (tab.isRendered()) {
          final UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, viewRoot.createUniqueId());
          entry.setTransient(true);
          entry.setOmit(true); // avoid submit
          final LabelWithAccessKey label = new LabelWithAccessKey(tab);
          entry.setLabel(label.getText());
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            ComponentUtils.putDataAttribute(entry, "tobago-index", index); // XXX todo, define a DataAttribute
          }
          menu.getChildren().add(entry);
        }
View Full Code Here

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

  private void createMenuItem(
      final FacesContext facesContext, final UIMenu menu, final String label, final Markup markup,
      final String sheetId) {
    final String id = markup.toString();
    final UIMenuCommand menuItem = (UIMenuCommand) CreateComponentUtils.createComponent(
        facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, id);
    menuItem.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", label));
    menuItem.setMarkup(markup);
    menuItem.setOnclick("/**/"); // XXX avoid submit
    ComponentUtils.putDataAttributeWithPrefix(menuItem, DataAttributes.SHEET_ID, sheetId);
    menu.getChildren().add(menuItem);
  }
View Full Code Here

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

    int index = 0;
    for (final UIComponent child : tabGroup.getChildren()) {
      if (child instanceof UITab) {
        final UITab tab = (UITab) child;
        if (tab.isRendered()) {
          final UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, viewRoot.createUniqueId());
          entry.setTransient(true);
          entry.setOmit(true); // avoid submit
          final LabelWithAccessKey label = new LabelWithAccessKey(tab);
          entry.setLabel(label.getText());
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            ComponentUtils.putDataAttribute(entry, "tobago-index", index); // XXX todo, define a DataAttribute
          }
          menu.getChildren().add(entry);
        }
View Full Code Here

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

  private static final Logger LOG = LoggerFactory.getLogger(MenuCommandRenderer.class);

  @Override
  public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
    final UIMenuCommand menu = (UIMenuCommand) component;
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    final boolean disabled = menu.isDisabled();
    final boolean firstLevel = RendererTypes.MENU_BAR.equals(menu.getParent().getRendererType());
    final LabelWithAccessKey label = new LabelWithAccessKey(menu);

    if (menu.getFacet(Facets.CHECKBOX) != null) {
      // checkbox menu
      final UISelectBooleanCheckbox checkbox = (UISelectBooleanCheckbox) menu.getFacet(Facets.CHECKBOX);
      final boolean checked = ComponentUtils.getBooleanAttribute(checkbox, Attributes.VALUE);
      final String image = checked ? "image/MenuCheckmark.gif" : null;
      final String hiddenId = checkbox.getClientId(facesContext);
      final CommandMap map = new CommandMap(new Command());
      encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, "selectBoolean");
      encodeHidden(writer, hiddenId, checked);
    } else if (menu.getFacet(Facets.RADIO) != null) {
      // radio menu
      final String clientId = menu.getClientId(facesContext);
      final UISelectOne radio = (UISelectOne) menu.getFacet(Facets.RADIO);
      final List<SelectItem> items = RenderUtils.getSelectItems(radio);
      final String hiddenId = radio.getClientId(facesContext);
      for (final SelectItem item : items) {
        final boolean checked = item.getValue().equals(radio.getValue());
        final String image = checked ? "image/MenuRadioChecked.gif" : null;
        final String labelText = item.getLabel();
        label.reset();

        if (labelText != null) {
          if (labelText.indexOf(LabelWithAccessKey.INDICATOR) > -1) {
            label.setup(labelText);
          } else {
            label.setText(labelText);
          }
        } else {
          LOG.warn("Menu item has label=null where clientId=" + clientId);
        }
        final String formattedValue = RenderUtils.getFormattedValue(facesContext, radio, item.getValue());
        final CommandMap map = new CommandMap(
            new Command(clientId, null, null, null, null, null, null, null, null, null));
        encodeItem(facesContext, writer, null, label, map, disabled, firstLevel, image, formattedValue, "selectOne");
      }
      encodeHidden(writer, hiddenId, getCurrentValue(facesContext, radio));
    } else {
      // normal menu command
      final String image = menu.getImage();
      final CommandMap map = new CommandMap(new Command(facesContext, menu));
      encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, null);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.