Package org.apache.myfaces.tobago.renderkit.html

Examples of org.apache.myfaces.tobago.renderkit.html.CommandMap


      throws IOException {
    if (ComponentUtils.getBooleanAttribute(component, Attributes.READONLY)
        || ComponentUtils.getBooleanAttribute(component, Attributes.DISABLED)) {
      return;
    }
    CommandMap commandMap = null;
    final Map<String, UIComponent> facets = component.getFacets();
    for (final Map.Entry<String, UIComponent> entry : facets.entrySet()) {
      final UIComponent facetComponent = entry.getValue();
      if (facetComponent.isRendered()
          && (facetComponent instanceof AbstractUICommand || facetComponent instanceof UIForm)) {
        if (commandMap == null) {
          commandMap = new CommandMap();
        }
        final String key = entry.getKey();
        commandMap.addCommand(key, new Command(facesContext, entry.getValue(), id));
      }
    }
    if (commandMap != null) {
      writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(commandMap), true);
    }
View Full Code Here


    }
  }

  public static boolean renderSheetCommands(final UISheet sheet, final FacesContext facesContext,
                                         final TobagoResponseWriter writer) throws IOException {
    CommandMap commandMap = null;
    for (final UIComponent child : sheet.getChildren()) {
      if (child instanceof UIColumnEvent) {
        final UIColumnEvent columnEvent = (UIColumnEvent) child;
        if (columnEvent.isRendered()) {
          final UIComponent selectionChild = child.getChildren().get(0);
          if (selectionChild != null && selectionChild instanceof AbstractUICommand && selectionChild.isRendered()) {
            final UICommand action = (UICommand) selectionChild;
            if (commandMap == null) {
              commandMap = new CommandMap();
            }
            commandMap.addCommand(columnEvent.getEvent(), new Command(facesContext, action, null));
          }
        }
      }
    }
    if (commandMap != null) {
View Full Code Here

    writer.writeClassAttribute(Classes.create(input));
    final Style style = new Style(facesContext, input);
    writer.writeStyleAttribute(style);
    final String onchange = ComponentUtils.getStringAttribute(input, Attributes.ONCHANGE);
    if (onchange != null) {
      final CommandMap map = new CommandMap();
      final Command change = new Command();
      change.setScript(onchange);
      map.addCommand("change", change);
    }
    int maxLength = -1;
    final String pattern = null;
    for (final Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
View Full Code Here

      if (command.getFacet(Facets.RADIO) != null) {
        return renderSelectOne(facesContext, toolBar, command, writer, width);
      } else if (command.getFacet(Facets.CHECKBOX) != null) {
        return renderSelectBoolean(facesContext, toolBar, command, writer, width);
      } else {
        final CommandMap map = new CommandMap(new Command(facesContext, command));
        return renderToolbarButton(
            facesContext, toolBar, command, writer, false, width, map, null);
      }
    }
  }
View Full Code Here

          currentValue = formattedValue;
        } else {
          checked = false;
        }

        final CommandMap map = new CommandMap(new Command());
        width = renderToolbarButton(
            facesContext, toolBar, command, writer, checked, width, map, formattedValue);
      }

      writer.startElement(HtmlElements.INPUT, null);
View Full Code Here

    final boolean checked = ComponentUtils.getBooleanAttribute(checkbox, Attributes.VALUE);
    final String clientId = checkbox.getClientId(facesContext);

    writer.startElement(HtmlElements.SPAN, checkbox);
    writer.writeClassAttribute(Classes.createWorkaround("toolBar", "selectBoolean", null));
    final CommandMap map = new CommandMap(new Command());
    width = renderToolbarButton(facesContext, toolBar, command, writer, checked, width, map, null);

    writer.startElement(HtmlElements.INPUT, null);
    writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
    writer.writeNameAttribute(clientId);
View Full Code Here

      // 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());
      final LabelWithAccessKey label = new LabelWithAccessKey(menu);
      encodeItem(facesContext, writer,
          menu, label, map, disabled, firstLevel, image, null, "selectBoolean", menu.getClientId());
      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();
        final LabelWithAccessKey label = new LabelWithAccessKey(labelText);
        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", clientId);
      }
      encodeHidden(writer, hiddenId, getCurrentValue(facesContext, radio));
    } else {
      // normal menu command
      final String image = menu.getImage();
      final CommandMap map = new CommandMap(new Command(facesContext, menu));
      final LabelWithAccessKey label = new LabelWithAccessKey(menu);
      encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, null, menu.getClientId());
    }
  }
View Full Code Here

                final String sorterId = columnId.substring(columnId.lastIndexOf(":") + 1) + "_" + UISheet.SORTER_ID;
                sortCommand = (UICommand) CreateComponentUtils.createComponent(
                    facesContext, UICommand.COMPONENT_TYPE, RendererTypes.LINK, sorterId);
                column.getFacets().put(Facets.SORTER, sortCommand);
              }
              final CommandMap map = new CommandMap();
              final Command click = new Command(sortCommand.getClientId(facesContext),
                  null, null, null, new String[]{sheet.getClientId(facesContext)}, null, null, null, null, null);
              map.setClick(click);
              writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);

              if (tip == null) {
                tip = "";
              } else {
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.renderkit.html.CommandMap

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.