I followed the advice from How to use enum values in f:selectItem(s) to build a h:selectOneMenu that takes the values of an enum. This works fine until I reload the page.
If I reload the page (Strg+R) what a user could do, the #{bean.relationship} property becomes null. All other properties, such as strings, numbers, etc. remain as they were before (Bean is @ViewScoped and @ManagedBean).
Here is the code from the JSF:
<h:selectOneMenu value="#{bean.relationship}">
<f:selectItems value="#{bean.relationshipTypes}"
var="types" itemValue="#{types}" itemLabel="#{types}" />
</h:selectOneMenu>
<h:inputText value="#{bean.name}" />
Here the code from the Enum:
public enum RelationshipType {
Family,
Friend
}
Here the code from the Bean:
private RelationshipType relationship; // plus getter & setter
private RelationshipType[] relationshipTypes;
private String name; // plus getter & setter
public RelationshipType[] getRelationshipTypes() {
return RelationshipType.values();
}
The enum is part of a larger entity. For ease of display a shortend version. Any idea?
@Geinmachi: Yet, other values stored in the bean are still there after the reload (e.g. name). So, why not for the property related to the enum?