1 Reply Latest reply on Apr 12, 2007 10:22 AM by Samuel Mendenhall


    Boris Temkin Newbie

      Hello sirs.

      I try call page someAction.xhtml that mapped to seam component someAction. Everything fine except of enum convertion.

      enum TypeEnum {

      class SomeActionBean implements SomeAction {
       private long id;
       private TypeEnum type;
       public void method() {

      <page view-id="/someAction.xhtml" action="#{someAction.method}">
       <param name="id" value="#{someAction.id}"/>
       <param name="type" value="#{completeAction.type}"/>

      When I call url

      logs from SomeAction.method shows that id= 2 but type is null (!)

      what I am doing wrong?
      The only one way that I found to work around is following:

      1. implement javax.faces.convert.Converter intrface in my own class.
      2. add to faces-config lines:

      3. change pages.xml to
      <page view-id="/someAction.xhtml" action="#{someAction.method}">
       <param name="id" value="#{someAction.id}"/>
       <param name="type" value="#{completeAction.type}" converterId="MyConverter"/>

      It is work, but (IMHO) it is ugly.

      I found that seam already has some EnumConverter, so i can use it.
      Please, point me to appropriate resources, where I can clerify the question.

      Thank you.

      PS: I use seam 1.2.0.PATCH1

        • 1. Re: EnumConverter
          Samuel Mendenhall Apprentice

          Use seams built in enum handling:

          Here is an example of handling a True/False Enum

          <h:outputLabel for="active">
           <span class="required">*</span>
           <s:decorate id="activeDecoration">
           <h:selectOneMenu id="active" value="#{testHome.instance.active}">
           <s:convertEnum />
           <s:enumItem enumValue="TRUE" label="True" />
           <s:enumItem enumValue="FALSE" label="False" />

          public enum BooleanEnum {
           private final String name;
           * Prevent instantiation and subclassing with a private constructor.
           private BooleanEnum(String name) {
           this.name = name;
           private static final Map INSTANCES = new HashMap();
           static {
           INSTANCES.put(TRUE.toString(), TRUE);
           INSTANCES.put(FALSE.toString(), FALSE);
           // ********************** Common Methods ********************** //
           public String toString() {
           return name;
           Object readResolve() {
           return getInstance(name);
           public static JobStatus getInstance(String name) {
           return (JobStatus) INSTANCES.get(name);

          And in the entity:

           public BooleanEnum getActive() {
           return active;
           public void setActive(BooleanEnum active) {
           this.active = active;