Reputation: 695
I have a rich:select
in my code as follows :
<rich:select style="width: 50" enableManualInput=false value="#{MyBean.Obj.id}">
<f:selectItems value="#{MyBean.objList}"/>
</rich:select>
On my page, if I open this dropdown, it shows the first element in the dropdown instead of that specified by the value attribute. If I now select one of the elements and then open it again, it still goes to the first element, not the selected one.
If I however replace rich:select
with h:selectOneMenu
with all the same attributes, it works fine. I can't use h:selectOneMenu
though as the richfaces styles are not applied to it.
Upvotes: 0
Views: 1782
Reputation: 1081
change <f:selectItems value="#{MyBean.objList}"/>
to <f:selectItems value="#{MyBean.objList}" var="obj" itemValue="obj.id"/>
and if your id is not a native Java class, then implement hashCode
and equals
method in it
Upvotes: 0
Reputation: 165
I think you need to use converter attribute of rich:select. Sometime I have same issues and always it is because rich:select fail mapping to appropriate value (in your situation it is three).
Upvotes: 0
Reputation: 3884
h:selectOneMenu
generates <select>
and that can't be styled very well.
The <rich:select>
doesn't have that kind of functionality, but it can be achieved with Javascript, take a look on my solution for a similar question.
Upvotes: 1