[jboss-user] [JBoss Seam] - Using enum for component attribute

mustaghattack do-not-reply at jboss.com
Thu May 24 12:31:01 EDT 2007


Hello,

I'm wondering if there is a simple way to bind a model property to a component attribute.

Here is a simple example :
I would like to persist the selectManyCheckbox layout attribute. In the model I would typically use an enum (independent of the UI values) like

enum Alignment { HORIZONTAL, VERTICAL }

and expect to use it this way
<h:selectManyCheckbox layout="#{myBean.alignment}" ...> where getAlignment in myBean return an Alignment object.
Obviously we need to define somewhere conversions rules which are pretty straightforward : Alignment.HORIZONTAL -> "lineDirection" etc ...

The ValueExpression mechanism call ELResolver to get myBean.alignment but then coerce the enum to a String by calling the name() method (as defined in the unified EL spec), which of course doesn't work.

I'm using Seam so I don't want to write a backed bean just to convert this value.
I though to write an EL function but it's supposed to be a view stuff isn't it ?

Any idea ?
Thanks,
Bruno

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

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



More information about the jboss-user mailing list