Reputation: 158
I need Internationalize items for the selectOneMenu JSF component. How can it be done for the List which received from database?
<p:selectOneMenu id="action" value="#{mapBean.newAction}" style="width:150px">
<f:selectItem itemLabel="Action" itemValue="Empty"
noSelectionOption="false" />
<f:selectItems value="#{mapBean.actions}" />
</p:selectOneMenu>
For the mapBean.actions I need dinamicaly change values according selected language For now I don't have an idea how implement this.
Upvotes: 0
Views: 416
Reputation: 391
As i understood your question you have list of objects with "Locale" property. And you want to display only items with specified locale in your selectOneMenu. You can do something like this to filter selectItems:
<p:selectOneMenu id="action" value="#{mapBean.newAction}" style="width:150px">
<f:selectItem itemLabel="Action" itemValue="Empty"
noSelectionOption="false" />
<f:selectItems value="#{mapBean.actions}"
var="item" itemDisabled="#{item.locale ne 'en'}"/>
</p:selectOneMenu>
And add this to css to your page to not display disabled items:
.ui-selectlistbox-item.ui-state-disabled {
display: none;
}
This is solution from this answer
Upvotes: 1