org.apache.myfaces.commons.converter
Class EnumConverter

java.lang.Object
  extended by org.apache.myfaces.commons.converter.EnumConverter
All Implemented Interfaces:
javax.faces.component.StateHolder, javax.faces.convert.Converter

@JSFConverter(name="mcc:convertEnum",
              tagClass="org.apache.myfaces.commons.converter.ConvertEnumTag",
              tagHandler="org.apache.myfaces.commons.converter.ConvertEnumTagHandler")
public class EnumConverter
extends Object
implements javax.faces.convert.Converter, javax.faces.component.StateHolder

Converts a Java 5 Enum. see Javadoc of JSF Specification

Author:
Stan Silvert

Field Summary
static String CONVERTER_ID
           
static String ENUM_ID
           
static String ENUM_NO_CLASS_ID
           
static String ENUM_NO_ENUM_CLASS
           
static String SEPARATOR
           
 
Constructor Summary
EnumConverter()
          Creates a new instance of EnumConverter
EnumConverter(Class targetClass)
           
 
Method Summary
 Object getAsObject(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, String value)
           
 String getAsString(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, Object value)
           
 Class getTargetClass()
          The enum class to be used for this converter as reference
 boolean isTransient()
           
 void restoreState(javax.faces.context.FacesContext context, Object state)
           
 Object saveState(javax.faces.context.FacesContext context)
           
 void setTargetClass(Class targetClass)
           
 void setTransient(boolean newTransientValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERTER_ID

public static final String CONVERTER_ID
See Also:
Constant Field Values

ENUM_ID

public static final String ENUM_ID
See Also:
Constant Field Values

ENUM_NO_CLASS_ID

public static final String ENUM_NO_CLASS_ID
See Also:
Constant Field Values

ENUM_NO_ENUM_CLASS

public static final String ENUM_NO_ENUM_CLASS
See Also:
Constant Field Values

SEPARATOR

public static final String SEPARATOR
See Also:
Constant Field Values
Constructor Detail

EnumConverter

public EnumConverter()
Creates a new instance of EnumConverter


EnumConverter

public EnumConverter(Class targetClass)
Method Detail

getAsString

public String getAsString(javax.faces.context.FacesContext facesContext,
                          javax.faces.component.UIComponent uiComponent,
                          Object value)
                   throws javax.faces.convert.ConverterException
Specified by:
getAsString in interface javax.faces.convert.Converter
Throws:
javax.faces.convert.ConverterException

getAsObject

public Object getAsObject(javax.faces.context.FacesContext facesContext,
                          javax.faces.component.UIComponent uiComponent,
                          String value)
                   throws javax.faces.convert.ConverterException
Specified by:
getAsObject in interface javax.faces.convert.Converter
Throws:
javax.faces.convert.ConverterException

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder

saveState

public Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder

setTransient

public void setTransient(boolean newTransientValue)
Specified by:
setTransient in interface javax.faces.component.StateHolder

isTransient

public boolean isTransient()
Specified by:
isTransient in interface javax.faces.component.StateHolder

getTargetClass

@JSFProperty
public Class getTargetClass()
The enum class to be used for this converter as reference


setTargetClass

public void setTargetClass(Class targetClass)


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.