public class ListConverter extends Object implements Converter<Object>
The omnifaces.ListConverter
is intented for use in specialized selection components which doesn't
use SelectItem
s as the source for their selectable items, but work directly via a List
of entities,
and therefore the SelectItemsConverter
isn't usable on them.
This converter allows you to populate a selection component with complex Java objects and have JSF convert those
automatically back without the need to provide a custom converter which may need to do the job based on possibly
expensive service/DAO operations. This converter automatically converts based on the Object.toString()
of the
selected item.
This converter is available by converter ID omnifaces.ListConverter
and should be used in combination
with <o:converter>
in order to be able to pass the List
source to it, which it can use
for conversion. Here's a basic usage example with PrimeFaces <p:pickList>
, which is one of the
few select components which doesn't use SelectItem
s as the source, but work directly via a List
.
<p:pickList value="#{bean.dualListModel}" var="entity" itemValue="#{entity}" itemLabel="#{entity.someProperty}"> <o:converter converterId="omnifaces.ListConverter" list="#{bean.dualListModel.source}" /> </p:pickList>
toString()
implementation
For detail, refer the javadoc of SelectItemsConverter
and substitute "SelectItemsConverter
" by
"ListConverter
" and "SelectItemsIndexConverter
" by "ListIndexConverter
".
DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE_PARAM_NAME
Constructor and Description |
---|
ListConverter() |
Modifier and Type | Method and Description |
---|---|
Object |
getAsObject(FacesContext context,
UIComponent component,
String value) |
String |
getAsString(FacesContext context,
UIComponent component,
Object value) |
void |
setList(List<?> list) |
public Object getAsObject(FacesContext context, UIComponent component, String value)
getAsObject
in interface Converter<Object>
public String getAsString(FacesContext context, UIComponent component, Object value)
getAsString
in interface Converter<Object>
public void setList(List<?> list)
Copyright © 2012–2022 OmniFaces. All rights reserved.