Reputation: 433
I've got a List of Numbers (range 500 - 5000, steps of 500). I would like to add a decimal dot 1000 -> 1.000; 2500 -> 2.500 etc. but just for the labels not to be saved as a value. I tried the following but it didnt work:
<h:selectOneMenu value="#{bean.selectedValue}">
<f:convertNumber type="currency" locale="de-DE" pattern="#,###" />
<f:selectItems itemValue="#{bean.selectItemslist}" var="item" itemLabel="#{item.label}" itemValue="#{item.value} />
</h:selectOneMenu>
But this didnt do anything :(
Tried several patterns and included integerOnly="true" but nothing seems to work :( Thanks for your help!
Upvotes: 2
Views: 1533
Reputation: 1108742
The converter applies on the item value only, not on the item label. That explains why it "fails". In this particular case, your best bet is to create a custom EL function, so that you end up something like this:
<f:selectItems ... itemLabel="#{my:formatNumber(item.label, '#,###')}" />
The JSF utility library OmniFaces has several, see also OmniFaces functions/Numbers showcase.
Upvotes: 6