예제 #1
0
  protected SelectItem createSelectItem(
      FacesContext context, UISelectItems uiSelectItems, Object object) {
    String var = (String) uiSelectItems.getAttributes().get("var");

    if (var != null) {
      context.getExternalContext().getRequestMap().put(var, object);

      Object itemLabelAsObject = uiSelectItems.getAttributes().get("itemLabel");
      Object itemValue = uiSelectItems.getAttributes().get("itemValue");
      String description = (String) uiSelectItems.getAttributes().get("itemDescription");
      Object itemDisabled = uiSelectItems.getAttributes().get("itemDisabled");
      Object itemEscaped = uiSelectItems.getAttributes().get("itemLabelEscaped");
      Object noSelection = uiSelectItems.getAttributes().get("noSelectionOption");

      if (itemValue == null) {
        itemValue = object;
      }

      String itemLabel =
          itemLabelAsObject == null ? String.valueOf(object) : String.valueOf(itemLabelAsObject);
      boolean disabled = itemDisabled == null ? false : Boolean.valueOf(itemDisabled.toString());
      boolean escaped = itemEscaped == null ? false : Boolean.valueOf(itemEscaped.toString());
      boolean noSelectionOption =
          noSelection == null ? false : Boolean.valueOf(noSelection.toString());

      return new SelectItem(
          itemValue, itemLabel, description, disabled, escaped, noSelectionOption);
    } else {
      return new SelectItem(object, String.valueOf(object));
    }
  }
예제 #2
0
 /** Return the value of the <code>renderLabelAsButton</code> property. */
 public boolean isRenderLabelAsButton() {
   if (renderLabelAsButton != null) {
     return renderLabelAsButton.booleanValue();
   }
   ValueBinding vb = getValueBinding("renderLabelAsButton");
   return vb != null ? ((Boolean) vb.getValue(getFacesContext())).booleanValue() : false;
 }
예제 #3
0
 /** Return the value of the <code>ignorePagination</code> property. */
 public boolean isIgnorePagination() {
   if (ignorePagination != null) {
     return ignorePagination.booleanValue();
   }
   ValueBinding vb = getValueBinding("ignorePagination");
   return vb != null ? ((Boolean) vb.getValue(getFacesContext())).booleanValue() : false;
 }
예제 #4
0
  protected SelectItem createSelectItem(
      FacesContext context, UISelectItems uiSelectItems, String itemLabel, Object itemValue) {
    String var = (String) uiSelectItems.getAttributes().get("var");

    if (var != null) {
      context.getExternalContext().getRequestMap().put(var, itemValue);

      String description = (String) uiSelectItems.getAttributes().get("itemDescription");
      Boolean disabled =
          Boolean.valueOf(((String) uiSelectItems.getAttributes().get("itemDisabled")));
      Boolean escaped =
          Boolean.valueOf(((String) uiSelectItems.getAttributes().get("itemLabelEscaped")));
      Boolean noSelectionOption =
          Boolean.valueOf(((String) uiSelectItems.getAttributes().get("noSelectionOption")));

      return new SelectItem(
          itemValue, itemLabel, description, disabled, escaped, noSelectionOption);
    } else {
      return new SelectItem(itemValue, itemLabel);
    }
  }
  @SuppressWarnings("rawtypes")
  public static void renderXHTMLStyleBooleanAttributes(ResponseWriter writer, UIComponent component)
      throws IOException {

    assert (writer != null);
    assert (component != null);

    Map attrMap = component.getAttributes();
    for (String attrName : BOOLEAN_ATTRIBUTES) {
      Object val = attrMap.get(attrName);
      if (val == null) {
        continue;
      }

      if (Boolean.valueOf(val.toString())) {
        writer.writeAttribute(attrName, true, attrName);
      }
    }
  }
예제 #6
0
  public static boolean shouldDecode(UIComponent component) {
    boolean disabled = Boolean.valueOf(String.valueOf(component.getAttributes().get("disabled")));
    boolean readonly = Boolean.valueOf(String.valueOf(component.getAttributes().get("readonly")));

    return !disabled && !readonly;
  }