I have the below piece of code:
<h:selectOneMenu value="#{serviceBean.selectedCountry}" class="form-control" id="code">
<f:selectItems value="#{serviceBean.countryVos}" var="s"
itemValue="#{s.id}" itemLabel="#{s.name} #{s.countryCode}"/>
</h:selectOneMenu>
and the below in my MangedBean :
@ManagedBean(name = "serviceBean")
@ViewScoped
public class ServiceBean extends ServiceConfig implements Serializable {
private List<CountryVo> countryVos;
private String selectedCountry;
private void getCountry() {
try {
this.countryVos = CountryDao.getInstance().getCountryData();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
Map<String, Object> sessionMap = externalContext.getSessionMap();
sessionMap.put("countryVos", this.countryVos);
} catch (Exception ex) {
Logger.getLogger(ServiceBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
public String getSelectedCountry() {
return selectedCountry;
}
public void setSelectedCountry(String selectedCountry) {
this.selectedCountry = selectedCountry;
}
}
I want to return in the selectedCountry
the Object countryVo
not the String of it, how can I do this?
when I tried to return object I got the below error :
Conversion Error setting value '33' for 'null Converter
33 is the value of the selected country id