- java.lang.Object
- 
- org.omnifaces.converter.SelectItemsIndexConverter
 
- 
 public class SelectItemsIndexConverter extends Object implements Converter<Object> The omnifaces.SelectItemsIndexConverteris a variant of theSelectItemsConverterwhich automatically converts based on the position (index) of the selected item in the list instead of theObject.toString()of the selected item.UsageThis converter is available by converter ID omnifaces.SelectItemsIndexConverter. Just specify it in theconverterattribute of the selection component holding<f:selectItems>.<h:selectOneMenu value="#{bean.selectedItem}" converter="omnifaces.SelectItemsIndexConverter"> <f:selectItems value="#{bean.availableItems}" /> </h:selectOneMenu>Pros and cons as compared toSelectItemsConverterThis converter has the following advantages over SelectItemsConverter:- No need to rely on Object.toString()method of the object.
- No need to extend the SelectItemsConverterwhenObject.toString()method of the object cannot be used.
- No need to expose the object's unique key in its Object.toString(),if that's a problem.
 This converter has the following disadvantage over SelectItemsConverter:- The "Validation Error: value is not valid" will never occur anymore for the case that the available select items has incompatibly changed during the postback due to a developer's mistake. The developer should make absolutely sure that exactly the same list is preserved on postback (e.g. by making it a property of a view scoped or broader scoped bean).
 - Since:
- 1.3
- Author:
- Patrick Dobler, Bauke Scholtz
- See Also:
- SelectItemsUtils,- SelectItemsCollector
 
- No need to rely on 
- 
- 
Field Summary- 
Fields inherited from interface jakarta.faces.convert.ConverterDATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE_PARAM_NAME
 
- 
 - 
Constructor SummaryConstructors Constructor Description SelectItemsIndexConverter()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetAsObject(FacesContext context, UIComponent component, String submittedValue)StringgetAsString(FacesContext context, UIComponent component, Object modelValue)
 
- 
- 
- 
Method Detail- 
getAsObjectpublic Object getAsObject(FacesContext context, UIComponent component, String submittedValue) - Specified by:
- getAsObjectin interface- Converter<Object>
 
 - 
getAsStringpublic String getAsString(FacesContext context, UIComponent component, Object modelValue) - Specified by:
- getAsStringin interface- Converter<Object>
 
 
- 
 
-