Here is my JSF's tag:
<p:selectOneMenu id="myLocales" value="#{propertyBean.localeId}" editable="true" >
<f:selectItem itemLabel="Select Locale" itemValue="" />
<f:selectItems value="#{propertyBean.locales.entrySet()}" var ="map" itemValue="#{map.key}" itemLabel="#{map.value}" />
</p:selectOneMenu>
Here is my propertyBean's getLocales() method :
public Map<Integer,String> getLocales() {
Session session = HibernateUtil.getSessionFactory().openSession();
List<Locale> locales = session.createCriteria(Locale.class)
.list();
Map<Integer,String> localeMap = new HashMap<Integer,String>();
for (Locale locale : locales) {
localeMap.put(locale.getLocaleId(), locale.getLocaleName());
}
return localeMap;
}
After form posts, I am expecting the integer which I am setting as key in the Map as LocaleId on the server side, but unfortunately I am getting the String Label as LocaleId on the server side. Can you tell me why this inversion is happening and how I can correct it.