I have a simple OneMenu in JSF:
@ManagedBean
@ViewScoped
public class ProductBean {
...
protected static Map<String, String> priceTypes;
...
getter & setter
}
<p:selectOneMenu id="sizeType" >
<f:selectItems value="#{productBean.priceTypes}" />
</p:selectOneMenu>
In my usecase, i want to preselect[1] an option out of “priceTypes” – how can i do that?
I am using Glassfish 3.1.2.2 with Primefaces 3.4.1
[1] See “selected” at http://www.w3schools.com/tags/tag_option.asp
I am not sure about pfaces, but in plain JSF you just have to set the
valueattribute in theselectOneMenutag, and make sure that the value returned by the bean is in the select list.Of course,
sizeTypemust mutch the key of your map.