public class LocalizableEnumConverter extends Object implements javax.faces.convert.Converter, Serializable
LocalizableEnumeration
.
LocalizableEnumeration
to an actual
LocalizableEnumeration
and vice versa. As expected, this converter can only do its work reliably when the localized
description is unique (case insensitive) within the enumerated set.<h:outputText value="#{car.carDetail.color}" converter="localizableEnumConverter}"/>
Constructor and Description |
---|
LocalizableEnumConverter() |
Modifier and Type | Method and Description |
---|---|
Object |
getAsObject(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent component,
String stringEnum)
Converts the supplied stringEnum to an object of type
LocalizableEnumeration . |
String |
getAsString(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent component,
Object enumeratedValue)
Converts the supplied enumeratedValue to a localized String consisting of the localized description of the enumerated
value.
|
public Object getAsObject(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String stringEnum)
LocalizableEnumeration
.getAsObject
in interface javax.faces.convert.Converter
facesContext
- Faces Context.component
- The UI component that stores the enumerated value.stringEnum
- The enum in String format to convert to a LocalizableEnumeration
.LocalizableEnumeration
or null when no enumerated value with the
supplied stringEnum exists.public String getAsString(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, Object enumeratedValue)
getAsString
in interface javax.faces.convert.Converter
facesContext
- Faces Context.component
- The UI component that stores the enumerated value.enumeratedValue
- The enum to convert to a localized String.LocalizableEnumeration
.Copyright © 2008–2018. All rights reserved.