我使用的是primefaces 4.0.7 .我使用了选择菜单,这个菜单显示了变量,但是值在Bean中为空。我能做什么配置吗?
这是部分xhtml代码;
<h:outputText value="#{etiketler.kullaniciTipi} : " />
<p:selectOneMenu id="kullaniciTipi" style="width:200px" value="#{kullaniciIslemleriBean.userRole}" >
<f:selectItems value="#{enumBean.kullaniciTipiValues}" var="kullaniciTipi"
itemLabel="#{kullaniciTipi.name}" itemValue="#{kullaniciTipi}" />
</p:selectOneMenu>
这里是kullaniciIslemleriBean代码的一部分;
private EnumBase.KullaniciTipi userRole;
public void Kaydet() {
if (userRole == null) {
System.out.println("null value");
return;
}
...
}
public EnumBase.KullaniciTipi getUserRole() {
return userRole;
}
public void setUserRole(EnumBase.KullaniciTipi userRole) {
this.userRole = userRole;
}
尝试将其存储为String,它将正常工作。如果你想储存的话作为Enum,然后尝试转换
<h:outputText value="#{etiketler.kullaniciTipi} : " />
<p:selectOneMenu id="kullaniciTipi" style="width:200px" value="#{kullaniciIslemleriBean.userRole}" >
<f:selectItems value="#{enumBean.kullaniciTipiValues}" var="kullaniciTipi"
itemLabel="#{kullaniciTipi.name}" itemValue="#{kullaniciTipi.name}" />
</p:selectOneMenu>
private String userRole;
public void Kaydet() {
if (userRole == null) {
System.out.println("null value");
return;
}
...
}
public String getUserRole() {
return userRole;
}
public void setUserRole(String userRole) {
this.userRole = userRole;
}