The o:selectItemGroups is an extension of UISelectItems which allows you to iterate over a
nested collection representing groups of select items. This is basically the UIComponent counterpart of
jakarta.faces.model.SelectItemGroup. There is no equivalent (yet) in the standard Faces API. Currently the
only way to represent SelectItemGroup in UI is to manually create and populate them in a backing bean which
can end up to be quite verbose.
Below example assumes a List<Category> as value wherein Category in turn has a
List<Product>.
<h:selectOneMenu value="#{bean.selectedProduct}" converter="omnifaces.SelectItemsConverter">
<f:selectItem itemValue="#{null}" />
<o:selectItemGroups value="#{bean.categories}" var="category" itemLabel="#{category.name}">
<f:selectItems value="#{category.products}" var="product" itemLabel="#{product.name}" />
</o:selectItemGroups>
</h:selectOneMenu>
| Info | Value |
|---|---|
| Component Type | org.omnifaces.component.model.SelectItemGroups |
| Handler Class | None |
| Renderer Type | None |
| Description | None |
| Name | Required | Type | Description |
|---|---|---|---|
binding | false | jakarta.el.ValueExpression
(must evaluate to jakarta.faces.component.UIComponent)
| The ValueExpression linking this component to a property in a backing bean. |
id | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| Component identifier of the UISelectItems component to be created. |
itemLabel | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The label of the select item group.
Defaults to the String representation of itemValue. |
itemValue | false | jakarta.el.ValueExpression
(must evaluate to java.lang.Object)
| The value of the select item group. This will be exposed to any nested UISelectItem(s) children. Defaults to the currently iterated select item group. |
rendered | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| Flag indicating whether or not this component should be rendered (during Render Response Phase), or processed on any subsequent form submit. The default value for this property is true. |
value | true | jakarta.el.ValueExpression
(must evaluate to java.lang.Object)
| Value expression pointing at any Collection or array. The member elements may be instances of SelectItem or any Java Object. In the case where the member elements are plain Java Objects, several additional attributes must be used by the page author to correctly identify the data to the enclosing UISelectOne or UISelectMany component, as shown in the following example. <h:selectOneListbox size="1" id="escape02" value="#{select05NoSelection.initialCollectionValues}"> <f:selectItems value="#{select05NoSelection.hobbitList}" var="n" itemValue="#{n.id}" itemLabel="#{n.bio}" itemDescription="#{n.description}" itemDisabled="#{n.disabled}" itemLabelEscaped="true" noSelectionValue="#{select05NoSelection.hobbitList[0]}"/> </h:selectOneListbox> In the preceding example, the value attribute on line 1 points to a Collection<HobbitBean>. HobbitBean is just a regular Java Object (POJO) that conforms to JavaBeans naming conventions for its properties. The value attribute on line 2 points to a List<HobbitBean>, though it could just as well point to a Collection, array, or jakarta.faces.model.DataModel. The attributes on lines 3 through 9, inclusive, leverage the fact that the value is a collection of POJOs. |
var | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The name of the EL variable which exposes the currently iterated select item group.
Defaults to item. |
Output generated by Vdldoc View Declaration Language Documentation Generator.