public class SelectItemsIndexConverter extends Object implements 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 |
---|---|
Object |
getAsObject(FacesContext context,
UIComponent component,
String submittedValue) |
String |
getAsString(FacesContext context,
UIComponent component,
Object modelValue) |
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue)
getAsObject
in interface Converter
public String getAsString(FacesContext context, UIComponent component, Object modelValue)
getAsString
in interface Converter