I have an issue with one of my SelectOneMenu in JSF.
I have a SelectOneMenu component bound with list of Enums, and the value given to the selectOneMenu is an array element like this :
<h:selectOneMenu id="menuOperatorOne" value="#{operandExpression.operators[0]}">
<f:selectItem itemValue="#{null}" itemLabel=" -- Select "></f:selectItem>
<f:selectItems value="#{currentBean.listComparaisonOperators}"/>
<f:ajax render="expressionForm"/>
</h:selectOneMenu>
The problem is that return only a String (the name of the Enum as String, not the object itself).
I know the code works well if I set the value of the selectOneMenu to a simple variable of my Enum Type in my managedBean like :
<h:selectOneMenu id="menuOperatorOne" value="#{currentBean.myEnumObject}">
So in my meaning my enums are all good and not the source of the problem.
How can I retrieve object enum in an array element ?
Thanks for your help !
EDIT after duplicate proposition :
Saying we have two bean variables like ;
private EnumType singleEnumObject;
private List<EnumType> listEnumObjects;
and we have two selectOneMenu in the JSf like (listComparaisonOperators contains my Enum values);
<h:selectOneMenu id="menuOperatorOne" value="#{currentBean.singleEnumObject}">
<f:selectItems value="#{currentBean.listComparaisonOperators}"/>
</h:selectOneMenu>
<h:selectOneMenu id="menuOperatorTwo" value="#{currentBean.listEnumObjects[0]}">
<f:selectItems value="#{currentBean.listComparaisonOperators}"/>
</h:selectOneMenu>
As you can see, they are pretty same identicals, just the second is linked to element array as value. But each of them have Enums in selectItems, and the very same treatment.
The first selectOneMenu will return Enum Object in "singleEnumObject", which is good.
The second selectOneMenu will return String in "listEnumObjects[0]" (enum name as string). Shouldn't I get my Enum Object, juste like the first SelectOneMenu ?
Does anybody have an idea of what am I doing wrong here ? Can someone provide me example where he retrieves Enum Object using array element in the SelectOneMenu value (and not single variable) ?
Thanks.