我正在尝试使用一个支持 bean 来实现一个 JSF selectOneMenu 项目。问题是 selectedItem 始终为空。这是代码:
.xhtml:
<h:selectOneMenu
value="#{componentFilterBean.selectedItem}">
<f:selectItems value="#{componentFilterBean.projects}" />
</h:selectOneMenu>
豆:
public class ComponentFilterBean {
String selectedItem = null;
private List<SelectItem> selectItems = null;
public String getSelectedItem() {
System.out.println("getSelectedItem = " + selectedItem);
return selectedItem;
}
public void setSelectedItem(String selectedItem) {
this.selectedItem = selectedItem;
System.out.println("setSelectedItem = " + selectedItem);
}
public List<SelectItem> getProjects() {
if (selectItems == null) {
selectItems = new ArrayList<SelectItem>();
selectItems.add(new SelectItem("Project1", "Project1"));
selectItems.add(new SelectItem("Project2", "Project2"));
selectItems.add(new SelectItem("Project3", "Project3"));
}
return selectItems;
}
}
面孔-config.xml:
<managed-bean>
<managed-bean-name>componentFilterBean</managed-bean-name>
<managed-bean-class>test.ComponentFilterBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
我正在使用 sun 实现(1.2 版)。该问题出现在 Jetty 6 和 WebSphere 6.1 上。
有人可以帮我解决这个问题吗?
基督教