如何解决如何在jsf中使用selectOneMenu对象的值不是String?
我有下面的代码:
<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>
以及我的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;
}
}
我想在selectedCountry
中返回对象countryVo
,而不是它的字符串,我该怎么做?
当我尝试返回对象时,出现以下错误:
“空转换器”的转换错误设置值“ 33”
33是所选国家/地区ID的值
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。