[jboss-user] [JBoss Seam] - selectItems and enums
Sammy8306
do-not-reply at jboss.com
Thu Jun 7 06:19:00 EDT 2007
I can edit a value with an enumerated type in the following way:
| <h:selectOneMenu value="#{EditEntryComponent.blogEntry_be.category}">
| <s:selectItems value="#{EditEntryComponent.values}" var="enum" label="#{enum.label}" noSelectionLabel="Please select : " />
| <s:convertEnum />
| </h:selectOneMenu>
|
EditEntryComponent.values points to:
| public BlogEntry.Enum_category[] getValues() {
| return BlogEntry.Enum_category.values();
| }
|
However, I would really like to omit this last function, and retrieve the values from the Enum_category enum directly. Does anybody see a way to express this in EL? I see a couple of problems:
* the Java Enum API exposes values(), which does not conform to the get/set convention: not really a problem, I can generate a getValues() static method in each enum declaration which delegates to values()
* I cannot use enhanced EL in s:selectItems (so it appears at least)
* even if I could, how would I make a call to a static method in EL (using possibly a fully qualified type, i.e. some.package.Enum_category.values() )
If someone sees a possibility or clever solution, please let me know...
(one solution I played with is to create the getValues() in the enum as mentioned, and to use an EL expr. like 'EditEntryComponent.blogEntry_be.category.values' in s:selectItems, so we retrieve the possible values from an instance. However, in this case I cannot retrieve the possible values if the instance is null...)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052039#4052039
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052039
More information about the jboss-user
mailing list