Object value = uiSelectItems.getValue();
private List<SelectItem> processUISelectItems(ELContext elContext, UISelectItems c) { List<SelectItem> selectItems = new ArrayList<SelectItem>(); UISelectItems itemsComponent = c; Object value = itemsComponent.getValue();
private Iterator<SelectItem> createUISelectItemsIterator(UISelectItems selectItems) { Object value = selectItems.getValue(); return createSelectItemsIterator(selectItems, value); }
private Iterator<SelectItem> createUISelectItemsIterator(UISelectItems selectItems) { Object value = selectItems.getValue(); return createSelectItemsIterator(selectItems, value); }
private Iterator<SelectItem> createUISelectItemsIterator(UISelectItems selectItems) { Object value = selectItems.getValue(); return createSelectItemsIterator(selectItems, value); }
public Object getValue() { Object value = super.getValue(); String var = getVar(); if (var != null && var.length() > 0) { return createSelectItems(value); } else { return value; } }
choices = ( (UISelectItems) kid).getValue();
private static Collection<SelectItem> collectFromUISelectItems(FacesContext context, UISelectItems uiSelectItems) { Object value = uiSelectItems.getValue(); if (value instanceof SelectItem) { // A single SelectItem can be added directly without any further processing. return Collections.singleton((SelectItem) value); } else if (value instanceof Object[]) { // An array of objects is supposed to be transformed by the SelectItems iteration construct. return collectFromUISelectItemsIterator(context, uiSelectItems, Arrays.asList((Object[]) value)); } else if (value instanceof Iterable) { // An iterable (Collection, List, etc) is also supposed to be transformed by the SelectItems iteration construct. return collectFromUISelectItemsIterator(context, uiSelectItems, (Iterable<?>) value); } else if (value instanceof Map) { // A map has its own algorithm for how it should be turned into a list of SelectItems. return SelectItemsBuilder.fromMap((Map<?, ?>)value); } else { // A value binding was specified, but of a type we don't support. throw new IllegalArgumentException(format(ERROR_UNKNOWN_SELECT_TYPE, value.getClass().toString())); } }
private static Collection<SelectItem> collectFromUISelectItems(FacesContext context, UISelectItems uiSelectItems) { Object value = uiSelectItems.getValue(); if (value instanceof SelectItem) { // A single SelectItem can be added directly without any further processing. return Collections.singleton((SelectItem) value); } else if (value instanceof Object[]) { // An array of objects is supposed to be transformed by the SelectItems iteration construct. return collectFromUISelectItemsIterator(context, uiSelectItems, Arrays.asList((Object[]) value)); } else if (value instanceof Iterable) { // An iterable (Collection, List, etc) is also supposed to be transformed by the SelectItems iteration construct. return collectFromUISelectItemsIterator(context, uiSelectItems, (Iterable<?>) value); } else if (value instanceof Map) { // A map has its own algorithm for how it should be turned into a list of SelectItems. return SelectItemsBuilder.fromMap((Map<?, ?>)value); } else { // A value binding was specified, but of a type we don't support. throw new IllegalArgumentException(format(ERROR_UNKNOWN_SELECT_TYPE, value.getClass().toString())); } }
/** * An override which wraps each UISelectItem(s) child in a {@link SelectItemGroup}. */ @Override public Object getValue() { List<SelectItemGroup> groups = new ArrayList<>(); createSelectItems(this, super.getValue(), SelectItemGroup::new, selectItemGroup -> { List<SelectItem> items = new ArrayList<>(); for (UIComponent child : getChildren()) { if (child instanceof UISelectItems) { createSelectItems(child, ((UISelectItems) child).getValue(), SelectItem::new, items::add); } else if (child instanceof UISelectItem) { items.add(createSelectItem(child, null, SelectItem::new)); } } selectItemGroup.setSelectItems(items.toArray(new SelectItem[items.size()])); groups.add(selectItemGroup); }); return groups; }
/** * An override which wraps each UISelectItem(s) child in a {@link SelectItemGroup}. */ @Override public Object getValue() { List<SelectItemGroup> groups = new ArrayList<>(); createSelectItems(this, super.getValue(), SelectItemGroup::new, selectItemGroup -> { List<SelectItem> items = new ArrayList<>(); for (UIComponent child : getChildren()) { if (child instanceof UISelectItems) { createSelectItems(child, ((UISelectItems) child).getValue(), SelectItem::new, items::add); } else if (child instanceof UISelectItem) { items.add(createSelectItem(child, null, SelectItem::new)); } } selectItemGroup.setSelectItems(items.toArray(new SelectItem[items.size()])); groups.add(selectItemGroup); }); return groups; }
/** * This method gets all select items that are expressed via {@link UISelectItem} or {@link UISelectItems} * children of the given parent component. * <p> * Note that if {@link SelectItemGroup} instances are present then those will be inserted directly in the returned list * and the using code still has to iterate over its children recursively to obtain all separate {@link SelectItem} instances. * * @param parent the parent whose children are scanned * @param context The involved faces context. * @return list of select items obtained from parent's children. */ public static List<SelectItem> collectFromParent(FacesContext context, UIComponent parent) { List<SelectItem> selectItems = new ArrayList<>(); // Iterate over all children of the parent component. Non-UISelectItem/s children are automatically skipped. for (UIComponent child : parent.getChildren()) { if (child instanceof UISelectItem) { UISelectItem uiSelectItem = (UISelectItem) child; selectItems.add(getFromUISelectItem(uiSelectItem)); } else if (child instanceof UISelectItems) { UISelectItems uiSelectItems = (UISelectItems) child; if (uiSelectItems.getValue() != null) { selectItems.addAll(collectFromUISelectItems(context, uiSelectItems)); } } } return selectItems; }
/** * This method gets all select items that are expressed via {@link UISelectItem} or {@link UISelectItems} * children of the given parent component. * <p> * Note that if {@link SelectItemGroup} instances are present then those will be inserted directly in the returned list * and the using code still has to iterate over its children recursively to obtain all separate {@link SelectItem} instances. * * @param parent the parent whose children are scanned * @param context The involved faces context. * @return list of select items obtained from parent's children. */ public static List<SelectItem> collectFromParent(FacesContext context, UIComponent parent) { List<SelectItem> selectItems = new ArrayList<>(); // Iterate over all children of the parent component. Non-UISelectItem/s children are automatically skipped. for (UIComponent child : parent.getChildren()) { if (child instanceof UISelectItem) { UISelectItem uiSelectItem = (UISelectItem) child; selectItems.add(getFromUISelectItem(uiSelectItem)); } else if (child instanceof UISelectItems) { UISelectItems uiSelectItems = (UISelectItems) child; if (uiSelectItems.getValue() != null) { selectItems.addAll(collectFromUISelectItems(context, uiSelectItems)); } } } return selectItems; }
protected SelectItem getNextFromUISelectItems(UISelectItems items) { Object value = items.getValue(); if (value instanceof SelectItem) { return (SelectItem) value; } else if (value instanceof SelectItem[]) { this.items = Arrays.asList((SelectItem[]) value).iterator(); return getNextSelectItem(); } else if (value instanceof Collection) { Collection c = (Collection) value; this.items = c.iterator(); return getNextSelectItem(); } else if (value instanceof Map) { this.items = new SelectItemsMapIterator((Map) value); return getNextSelectItem(); } else { // throw new IllegalArgumentException(); return getNextSelectItem(); } }
private Iterator<SelectItem> newSelectItemsIterator(final UISelectItems component) { final String var = (String) component.getAttributes().get("var"); SelectItems selectItems = new SelectItems(component.getValue()) { @Override protected SelectItem convertToSelectItem(final Object value) { return FacesUtils.doWithRequestScopeVariable(SelectItemsIterator.this.context, var, value, new Callable<SelectItem>() { public SelectItem call() throws Exception { Map<String, Object> attrs = component.getAttributes(); Object itemValue = firstNonNullValue(attrs.get("itemValue"), value); String itemLabel = getStringValue(firstNonNullValue(attrs.get("itemLabel"), itemValue)); SelectItem item = new SelectItem(itemValue, itemLabel); item.setDescription(getStringValue(attrs.get("itemDescription"))); item.setEscape(getBooleanValue(attrs.get("itemLabelEscaped"))); item.setDisabled(getBooleanValue(attrs.get("itemDisabled"))); item.setNoSelectionOption(getBooleanValue(firstNonNullValue( attrs.get("noSelectionOption"), attrs.get("noSelectionValue")))); return item; } }); } }; return selectItems.iterator(); } }
} else if (kid instanceof UISelectItems) { UISelectItems ui = (UISelectItems) kid; Object value = ui.getValue(); if (value != null) { if (value instanceof SelectItem) {
} else if (kid instanceof UISelectItems) { UISelectItems ui = (UISelectItems) kid; Object value = ui.getValue(); if (value != null) { if (value instanceof SelectItem) {
} else if (kid instanceof UISelectItems) { UISelectItems ui = (UISelectItems) kid; Object value = ui.getValue(); if (value != null) { if (value instanceof SelectItem) {
} else if (kid instanceof UISelectItems) { UISelectItems ui = (UISelectItems) kid; Object value = ui.getValue(); if (value != null) { if (value instanceof SelectItem) {