[jboss-user] [JBoss Seam] - Re: Creating a simple selectOneMenu
mars1412
do-not-reply at jboss.com
Tue Jan 8 12:13:11 EST 2008
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)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4117994#4117994
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4117994
More information about the jboss-user
mailing list