- 
        1. Re: selectItems and enumssammy8306 Jun 7, 2007 6:46 AM (in response to sammy8306)Hm, nevermind.... the last solution I sketched, actually works. Even for null values of the enum type. Don't know where I screwed up the initial test of this solution, but it serves me well now. I can generate a selectlist for an enumeration, solely based on the type declaration (ok, given a value of that type actually... without repeating parts of the enum declaration in the xhtml code), which is what I was after. 
 Maybe it is an idea to incorporate this kind of functionality into s:selectitems (based on the always available values() and name() function on enums)?
- 
        2. Re: selectItems and enumsdavidfed Jun 14, 2007 7:39 PM (in response to sammy8306)Can you post the code you came up with? I tried some things based on your description but am not succeeding. 
- 
        3. Re: selectItems and enumssammy8306 Jun 16, 2007 12:24 PM (in response to sammy8306)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??
- 
        4. Re: selectItems and enumssammy8306 Jun 16, 2007 12:37 PM (in response to sammy8306)Note to self: getValues() of course is not a static method, which explains the failure. I would like to make it static, but if I do it is not recognized as a valid getter method by the EL-resolver. Back to square one (though it is a nice, working solution for non-null enum values). 
- 
        5. Re: selectItems and enumsdavidfed Jun 18, 2007 5:55 PM (in response to sammy8306)Yep, that's what I tried and that's how it didn't work. So I just have an external getter for now. 
 It looks like Seam 1.3 EL will allow Enum.values() in a value expression. That will simplify this and a number of things like it.
- 
        6. Re: selectItems and enumssammy8306 Jun 19, 2007 2:56 AM (in response to sammy8306)Oh, that would be cool, where did you see that? 
- 
        7. Re: selectItems and enumsdavidfed Jun 20, 2007 11:11 PM (in response to sammy8306)It shows up with jboss-el. It was an item in the release notes. 
- 
        8. Re: selectItems and enumsutdrew Dec 31, 2007 11:28 AM (in response to sammy8306)I have been unable to find any example of using something like #{EnumClass.values()} in the documentation. When I try it seam tries to resolve EnumClass as a managed component and fails. Can anyone help me out here? <s:selectItems value="#{EnumClass.values()}" /> <s:convertEnum />
 I'm using Seam 2.0.0 GA.
- 
        9. Re: selectItems and enumspmuir Jan 2, 2008 5:33 AM (in response to sammy8306)AFAIK this isn't possible, you need to expose your Enum values e.g. via an @Factory 
- 
        10. Re: selectItems and enumsnicoliniyo Jan 2, 2008 10:47 AM (in response to sammy8306)This worked for me: ... @DataModel private List<Pais> paisList; @Factory("paisList") public String listAll() { personList= entityManager.createQuery("from Pais").getResultList(); } ...
 xhtml:... <h:selectOneMenu value="#{estePais.formaAplicacionRetenciones}"> <s:convertEnum></s:convertEnum> <s:enumItem label="#{m['OPCIONIMPUESTOPORDENTRO']}" enumValue="PORDENTRO"></s:enumItem> <s:enumItem label="#{m['OPCIONIMPUESTOPORFUERA']}" enumValue="PORFUERA"></s:enumItem> </h:selectOneMenu> ..
 Wher Enum Values are: PORDENTRO, PORFUERA
 Hope to give u some lights!
 
     
     
     
    