0

I would like to provide a h:selectOneMenu in many languages. In fact just the first element of the box has to be in many languages. This element label is "no choice". The rest of the element are dynamically retrieved from a data base and can be anything. So they don't have to be translated. I have set the resource key in the model that builds the list items and that key just gets displayed as it is.

public List<SelectItem> getItems() {
    List<SelectItem> items = new ArrayList<SelectItem>();
    // add other items to the list
    // code has been removed
    items.add(0, new SelectItem("null", "#{messages.no_choice}"));
    return items;
}

I have read other which suggest to do as follows:

<h:selectOneMenu value="#{bean.orderStatus}">
<f:selectItems value="#{bean.orderStatuses}" var="orderStatus" 
    itemValue="#{orderStatus}" itemLabel="#{msg[orderStatus.name]}" />

but this can't work for as only one element in my list is meant to be translatable.

Thanks

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
edmond
  • 833
  • 3
  • 13
  • 31
  • 1
    This is the *n*th time that one had to remove [java] tag from your JSF question. Can you please take that as a hint to not add that anymore to a future JSF question? Only when you have a problem which is demonstratable in a plain Java application class with a `main()` method, then use [java] tag (and reconsider the relevance of [jsf] tag). – BalusC Nov 04 '15 at 10:49
  • 1
    As to the concrete problem, why don't you just use `` for that default item? See also http://stackoverflow.com/questions/11360030/best-way-to-add-a-nothing-selected-option-to-a-selectonemenu-in-jsf – BalusC Nov 04 '15 at 10:49

0 Answers0