public class SelectItemsIndexConverter extends Object implements jakarta.faces.convert.Converter<Object>
The omnifaces.SelectItemsIndexConverter
is a variant of the SelectItemsConverter
which
automatically converts based on the position (index) of the selected item in the list instead of the
Object.toString()
of the selected item.
This converter is available by converter ID omnifaces.SelectItemsIndexConverter
. Just specify it in the
converter
attribute of the selection component holding <f:selectItems>
.
<h:selectOneMenu value="#{bean.selectedItem}" converter="omnifaces.SelectItemsIndexConverter"> <f:selectItems value="#{bean.availableItems}" /> </h:selectOneMenu>
SelectItemsConverter
This converter has the following advantages over SelectItemsConverter
:
Object.toString()
method of the object.SelectItemsConverter
when Object.toString()
method of the object cannot be
used.Object.toString()
,if that's a problem.
This converter has the following disadvantage over SelectItemsConverter
:
SelectItemsUtils
,
SelectItemsCollector
Constructor and Description |
---|
SelectItemsIndexConverter() |
Modifier and Type | Method and Description |
---|---|
Object |
getAsObject(jakarta.faces.context.FacesContext context,
jakarta.faces.component.UIComponent component,
String submittedValue) |
String |
getAsString(jakarta.faces.context.FacesContext context,
jakarta.faces.component.UIComponent component,
Object modelValue) |
Copyright © 2012–2020 OmniFaces. All rights reserved.