Package javax.faces.component

Examples of javax.faces.component.UISelectItem


                    return false;
                }
            }
            if (child instanceof UISelectItem)
            {
                UISelectItem uiSelectItem = (UISelectItem) child;
                Object item = uiSelectItem.getValue();
                if (item == null)
                {
                    // no value attribute --> create the SelectItem out of the other attributes
                    Object itemValue = uiSelectItem.getItemValue();
                    String label = uiSelectItem.getItemLabel();
                    String description = uiSelectItem.getItemDescription();
                    boolean disabled = uiSelectItem.isItemDisabled();
                    boolean escape = uiSelectItem.isItemEscaped();
                    boolean noSelectionOption = uiSelectItem.isNoSelectionOption();
                    if (label == null)
                    {
                        label = itemValue.toString();
                    }
                    item = new SelectItem(itemValue, label, description, disabled, escape, noSelectionOption);
                }
                else if (!(item instanceof SelectItem))
                {
                    ValueExpression expression = uiSelectItem.getValueExpression("value");
                    throw new IllegalArgumentException("ValueExpression '"
                            + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
                            + RendererUtils.getPathToComponent(child) + " does not reference an Object of type SelectItem");
                }
                _nextItem = (SelectItem) item;
View Full Code Here


    public void testGetSelectItem() {
        UISelectOne selectOne = new UISelectOne();
        selectOne.getChildren().add(new UISelectItemStub("value1", "label1", "description1", false, false, false));
        selectOne.getChildren().add(new UISelectItemStub("value2", "label2", "description2", false, true, true));

        UISelectItem item = new UISelectItem();
        item.setValue(new SelectItem("value3", "label3", "description3", true, true, true));
        selectOne.getChildren().add(item);

        // non select item at end
        UIParameter param = new UIParameter();
        param.setName("param");
        param.setValue("paramValue");
        selectOne.getChildren().add(param);

        checkSelectItems(asList(SelectUtils.getSelectItems(facesContext, selectOne)));

        // non select item in middle
        selectOne = new UISelectOne();
        selectOne.getChildren().add(new UISelectItemStub("value1", "label1", "description1", false, false, false));
        selectOne.getChildren().add(param);
        selectOne.getChildren().add(new UISelectItemStub("value2", "label2", "description2", false, true, true));
        checkTwoSelectItems(asList(SelectUtils.getSelectItems(facesContext, selectOne)));

        // non select item as value cause IllegalArgumentException
        item = new UISelectItem();
        item.setValue(new UISelectItem());
        selectOne.getChildren().add(item);
        try {
            SelectUtils.getSelectItems(facesContext, selectOne);
        } catch (Exception e) {
            if (!(e instanceof IllegalArgumentException)) {
View Full Code Here

   
    while(children.hasNext()) {
      UIComponent child = children.next();
     
      if(child instanceof UISelectItem) {
        UISelectItem selectItem = (UISelectItem) child;
       
        items.add(new SelectItem(selectItem.getItemValue(), selectItem.getItemLabel()));
      } else if(child instanceof UISelectItems) {
        Object selectItems = ((UISelectItems) child).getValue();
     
        if(selectItems instanceof SelectItem[]) {
          SelectItem[] itemsArray = (SelectItem[]) selectItems;
View Full Code Here

        {
            lastIndex++;
            UIComponent co = ico.next();
            if (!(co instanceof UISelectItem))
                continue;
            UISelectItem si = (UISelectItem)co;
            Object ov = si.getItemValue();
            if (ObjectUtils.isEmpty(ov) && hasEmpty)
                continue;
            if (oe==null)
            {   // remove obsolete items
                lastIndex--;
View Full Code Here

        }
    }

    public void addSelectItem(UIComponent input, TextResolver textResolver, OptionEntry e)
    {
        UISelectItem selectItem = new UISelectItem();
        // set value
        selectItem.setItemValue(e.getValueString());
        // set text
        String text = e.getText();
        text = textResolver.resolveText(text);
        selectItem.setItemLabel(text);
        // add item
        input.getChildren().add(selectItem);
    }
View Full Code Here

                    return false;
                }
            }
            if (child instanceof UISelectItem)
            {
                UISelectItem uiSelectItem = (UISelectItem) child;
                Object item = uiSelectItem.getValue();
                if (item == null)
                {
                    Object itemValue = ((UISelectItem) child).getItemValue();
                    String label = ((UISelectItem) child).getItemLabel();
                    String description = ((UISelectItem) child)
View Full Code Here

        LOG.debug("kid " + kid.getClass().getName());
      }
      if (kid instanceof UISelectItem) {
        Object value = ((UISelectItem) kid).getValue();
        if (value == null) {
          UISelectItem item = (UISelectItem) kid;
          if (kid instanceof org.apache.myfaces.tobago.component.UISelectItem) {
            list.add(new org.apache.myfaces.tobago.model.SelectItem(
                (org.apache.myfaces.tobago.component.UISelectItem) kid));
          } else {
            list.add(new SelectItem(item.getItemValue() == null ? "" : item.getItemValue(),
                item.getItemLabel(),
                item.getItemDescription()));
          }
        } else if (value instanceof SelectItem) {
          list.add((SelectItem) value);
        } else {
          throw new IllegalArgumentException("TYPE ERROR: value NOT instanceof SelectItem. type="
View Full Code Here

                    return false;
                }
            }
            if (child instanceof UISelectItem)
            {
                UISelectItem uiSelectItem = (UISelectItem) child;
                Object item = uiSelectItem.getValue();
                if (item == null)
                {
                    // no value attribute --> create the SelectItem out of the other attributes
                    Object itemValue = uiSelectItem.getItemValue();
                    String label = uiSelectItem.getItemLabel();
                    String description = uiSelectItem.getItemDescription();
                    boolean disabled = uiSelectItem.isItemDisabled();
                    boolean escape = uiSelectItem.isItemEscaped();
                    boolean noSelectionOption = uiSelectItem.isNoSelectionOption();
                    if (label == null)
                    {
                        label = itemValue.toString();
                    }
                    item = new SelectItem(itemValue, label, description, disabled, escape, noSelectionOption);
                }
                else if (!(item instanceof SelectItem))
                {
                    ValueExpression expression = uiSelectItem.getValueExpression("value");
                    throw new IllegalArgumentException("ValueExpression '"
                            + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
                            + RendererUtils.getPathToComponent(child) +
                            " does not reference an Object of type SelectItem");
                }
View Full Code Here

    while (kids.hasNext()) {
      UIComponent kid = kids.next();
      if (kid instanceof UISelectItem) {
        Object value = ((UISelectItem) kid).getValue();
        if (value == null) {
          UISelectItem item = (UISelectItem) kid;
          list.add(new SelectItem(item.getItemValue(), item.getItemLabel(), item.getItemDescription(), item.isItemDisabled()));
        } else if (value instanceof SelectItem) {
          list.add((SelectItem)value);
        } else {
          String valueClass = (value != null ? "'" + value.getClass().getName() + "'" : "");
          throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_ATTRIBUTE_VALUE, valueClass, "<selectItem>"));
View Full Code Here

        }
       
        ArrayList<SelectItem> list = new ArrayList<SelectItem>();
        for (UIComponent kid : component.getChildren()) {
            if (kid instanceof UISelectItem) {
                UISelectItem item = (UISelectItem) kid;
                Object value = item.getValue();
               
                if (value == null) {
                    list.add(new SelectItem(item.getItemValue(),
                                            item.getItemLabel(),
                                            item.getItemDescription(),
                                            item.isItemDisabled(),
                                            item.isItemEscaped()));
                } else if (value instanceof SelectItem) {
                    list.add((SelectItem) value);
                } else {
                    throw new IllegalArgumentException(
                        MessageUtils.getExceptionMessageString(
View Full Code Here

TOP

Related Classes of javax.faces.component.UISelectItem

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.