public class SelectItemsIndexConverter
extends java.lang.Object
implements javax.faces.convert.Converter
The SelectItemsIndexConverter
automatically converts between the index of the select
item value and the select item value itself based on its position in the associated select items for the component
for which conversion is taking place.
This converter has the following advantages over SelectItemsConverter
:
toString()
method of the object.SelectItemsConverter
when toString()
method of the object cannot be
used.
This converter has the following disadvantage over SelectItemsConverter
:
This converter is available by converter ID omnifaces.SelectItemsIndexConverter
. Basic usage example:
<h:selectOneMenu value="#{bean.selectedEntity}" converter="omnifaces.SelectItemsIndexConverter"> <f:selectItems value="#{bean.availableEntities}" var="entity" itemValue="#{entity}" itemLabel="#{entity.someProperty}" /> </h:selectOneMenu>
Constructor and Description |
---|
SelectItemsIndexConverter() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getAsObject(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
java.lang.String submittedValue) |
java.lang.String |
getAsString(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
java.lang.Object modelValue) |
public java.lang.Object getAsObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String submittedValue)
getAsObject
in interface javax.faces.convert.Converter
public java.lang.String getAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object modelValue)
getAsString
in interface javax.faces.convert.Converter