Ok, here is the final way:
- Register the standard enum converter in faces-config.xml (optional):
java.lang.Enum
javax.faces.convert.EnumConverter
Add a function for example to a managed bean which converts the Enum values to an array of SelectItems:
@ManagedBean
public class GenderBean {
public SelectItem[] getGenderValues() {
SelectItem[] items = new SelectItem[Gender.values().length];
int i = 0;
for(Gender g: Gender.values()) {
items[i++] = new SelectItem(g, g.getLabel());
}
return items;
}
}
Then bind this function to the selectOneMenu in JSF:
That's it! Not the first explanation for this problem on the net. But i think it's the easiest & shortest one ;)