Hello,
I have a combobox where I need to display the empty line by default (by adding f:selectItem). But as result, there is an empty line in the combo but the first element shown is the first element in the list SelectItem allEtat. The component combo box is declared as following
<h:selectOneMenu id="etat" value="#{abstractMateriel.etat}" styleClass="selectOneMenu"> <f:selectItem itemLabel="" itemValue="" /> <f:selectItems value="#{gestionMateriel.allEtat}" /> </h:selectOneMenu>
In my backing bean, i have
private final List<SelectItem> allEtat = new ArrayList<SelectItem>(); for (String s : Util.ETAT.keySet()) { allEtat.add(new SelectItem(Util.ETAT.get(s), s)); }
ETAT is a HashMap (for the moment, we put in HashMap all the hard-values)
Please tell me why the empty line is not chosen by default?
Thanks a lot
Hi,
I don't know why. But you can do the same thing with s:selectItems with the attirbute noSelectionLabel.
Regards,
Juan