[jboss-user] [JBoss Seam] - Re: selectItems and enums
Sammy8306
do-not-reply at jboss.com
Sat Jun 16 12:24:16 EDT 2007
Here's the code for the enum:
| public enum Enum_level
| {
| GOOD("Good"), AVERAGE("Average"), BAD("Baaad!") ;
|
| private String label;
|
| Enum_level (String label)
| {
| this.label = label;
| }
|
| public String getLabel()
| {
| return label;
| }
|
| public Enum_level[] getValues() {
|
| return Enum_level.values();
|
| }
|
| public String toString()
| {
| return label;
| }
| }
|
|
and here's the accompanying jsf code:
| <h:selectOneMenu id="level" value="#{ViewBlogComponent.reply_r.level}">
| <s:selectItems value="#{ViewBlogComponent.reply_r.level.values}" var="enum" label="#{enum.label}" noSelectionLabel="Please select : "/>
| <s:convertEnum/>
| </h:selectOneMenu>
|
However, it turns out that the problem of not being able to get enum values from non-initialized references is still there. I think the EL-resolver just refuses to call getValues(), when (in this case) getLevel() returns null. Though it can safely do so, since it is a static accessor. Bummer :-( I really hoped this would work... this should be possible, right??
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054970#4054970
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054970
More information about the jboss-user
mailing list