[jboss-user] [JBoss Seam] - EnumConverter

lagranzh do-not-reply at jboss.com
Wed Apr 11 21:49:35 EDT 2007


Hello sirs.

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


  | enum TypeEnum {
  | type1
  | }
  |  


  | @Stateless
  | @Name("someAction")
  | class  SomeActionBean implements SomeAction {
  |    private long id;
  |    private TypeEnum type;
  | 
  |    public void method() {
  |    ....
  |    }
  |   ....
  | }
  | 

pages.xml:

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

When I call url

  | http://localhost:8080/myapp/someAction.seam?id=2&type=type1
  | 

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:

  |    <converter>
  | 	   <converter-id>MyConverter</converter-id>
  | 	   <converter-class>mypakage.MyEnumConverter</converter-class>
  | 	</converter>   
  | </faces-config>

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"/>        
  | </page>
  | 

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


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036590#4036590

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036590



More information about the jboss-user mailing list