This content has been marked as final.
Show 2 replies
-
1. Re: Creating a simple selectOneMenu
mars1412 Jan 8, 2008 12:13 PM (in response to felixk2)i think this should be possible using s:enumItem and s:convertEnum,
but you should also consider using a java-enumeration at entity-bean level:public enum CustomerStatus { INACTIVE, ACTIVE; public String getLabel() { return this.name(); //return whatever name you wanna see } }
then use this enum on your entity bean:@Enumerated(EnumType.STRING) @NotNull public CustomerStatus getStatus() { return status; }
then make the enum values available in the pages via a factory:@Name("customerStatusFactory") public class CustomerStatusFactory { @Factory("customerStatus") public CustomerStatus[] getCustomerStatus() { return CustomerStatus.values(); } }
in your page, use the enum:<h:selectOneMenu value="#{customerHome.instance.status}"> <s:selectItems value="#{customerStatus}" var="cus" label="#{cus.label}" noSelectionLabel="Please select" /> <s:convertEnum /> </h:selectOneMenu>
U may also checkout the examples\ui\src\org\jboss\seam\example\ui example (Person-entity) -
2. Re: Creating a simple selectOneMenu
felixk2 Jan 9, 2008 12:00 PM (in response to felixk2)Thank you very much for that answer. It works perfectly with your method.
-Felix