Package org.apache.myfaces.tobago.component

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


  }

  private void createMenuItem(
      final FacesContext facesContext, UIMenu menu, String label, Markup markup, 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.SHEETID, sheetId);
    menu.getChildren().add(menuItem);
  }
View Full Code Here


    int index = 0;
    for (UIComponent child : (List<UIComponent>) tabGroup.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, "entry-" + index);
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          entry.setLabel(label.getText());
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            entry.setOnclick(JQueryUtils.selectId(clientId)
                + ".find('.tobago-tab[tabgroupindex=" + index + "]')"
                + ".click();"
                + "if (event.stopPropagation === undefined) { "
                + "  event.cancelBubble = true; " // IE
                + "} else { "
View Full Code Here

  }

  private void createMenuItem(
      final FacesContext facesContext, UIMenu menu, String label, Markup markup, 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.SHEETID, sheetId);
    menu.getChildren().add(menuItem);
  }
View Full Code Here

    return fileMenu;

  }

  private void addMenuCommand(UIMenu fileMenu) {
    UIMenuCommand command = (UIMenuCommand)
        FacesContext.getCurrentInstance().getApplication().createComponent(UIMenuCommand.COMPONENT_TYPE);
    command.getAttributes().put("label", "test"+fileMenu.getChildCount());
    // TODO setAction
    fileMenu.getChildren().add(command);
  }
View Full Code Here

      writer.endElement(HtmlElements.OL);
    }
  }

  private void createMenuItem(final FacesContext facesContext, UIMenu menu, String label, String action, String id) {
    UIMenuCommand menuItem = (UIMenuCommand) CreateComponentUtils.createComponent(
        facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, id);
    menuItem.setOnclick(action);
    menuItem.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", label));
    menu.getChildren().add(menuItem);
  }
View Full Code Here

  private static final String MENU_ACCELERATOR_KEYS = "menuAcceleratorKeys";

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

    boolean disabled = menu.isDisabled();
    boolean firstLevel = RendererTypes.MENU_BAR.equals(menu.getParent().getRendererType());
    LabelWithAccessKey label = new LabelWithAccessKey(menu);
    String clientId = menu.getClientId(facesContext);
    String submit = HtmlRendererUtils.createSubmitAction(clientId, true, null, null);

    if (menu.getFacet(Facets.CHECKBOX) != null) {
      // checkbox menu
      UISelectBooleanCheckbox checkbox = (UISelectBooleanCheckbox) menu.getFacet(Facets.CHECKBOX);
      boolean checked = ComponentUtils.getBooleanAttribute(checkbox, Attributes.VALUE);
      String image = checked ? "image/MenuCheckmark.gif" : null;
      String hiddenId = checkbox.getClientId(facesContext);
      // the function toggles true <-> false
      String setValue = JQueryUtils.selectId(hiddenId)
          + ".each(function(){$(this).val($(this).val() == 'true' ? 'false' : 'true')}); ";
      encodeItem(facesContext, writer, menu, label, setValue + submit, disabled, firstLevel, image);
      encodeHidden(writer, hiddenId, checked);
    } else if (menu.getFacet(Facets.RADIO) != null) {
      // radio menu
      UISelectOne radio = (UISelectOne) menu.getFacet(Facets.RADIO);
      List<SelectItem> items = RenderUtils.getSelectItems(radio);
      String hiddenId = radio.getClientId(facesContext);
      for (SelectItem item : items) {
        boolean checked = item.getValue().equals(radio.getValue());
        String image = checked ? "image/MenuRadioChecked.gif" : null;
View Full Code Here

    return fileMenu;

  }

  private void addMenuCommand(UIMenu fileMenu) {
    UIMenuCommand command = (UIMenuCommand)
        FacesContext.getCurrentInstance().getApplication().createComponent(UIMenuCommand.COMPONENT_TYPE);
    command.getAttributes().put("label", "test"+fileMenu.getChildCount());
    // TODO setAction
    fileMenu.getChildren().add(command);
  }
View Full Code Here

TOP

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

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.