0 Replies Latest reply on May 24, 2007 12:31 PM by Bieth Bruno

    Using enum for component attribute

    Bieth Bruno Newbie

      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