Jsf 2 如何检索JSF-rich:select控件的选定值?
我有一个这样的组合框:Jsf 2 如何检索JSF-rich:select控件的选定值?,jsf-2,richfaces,managed-bean,Jsf 2,Richfaces,Managed Bean,我有一个这样的组合框: <rich:select id="foo" value="#{fooVo.selectedFoo}" defaultLabel="Please select one"> <f:selectItems value="#{fooVo.fooList}"/> </rich:select> public List<SelectItem> processFooList() { ... List<SelectItem
<rich:select id="foo" value="#{fooVo.selectedFoo}" defaultLabel="Please select one">
<f:selectItems value="#{fooVo.fooList}"/>
</rich:select>
public List<SelectItem> processFooList() {
...
List<SelectItem> theList = theDao.getFooList();
return theList;
}
假设selectedFoo
应填写所选条目,我可以知道如何解决此问题吗
2012年8月15日更新-傻瓜如何更新?
列表的结构在DAO中:
public List<SelectItem> getFooList() {
List<SelectItem> newList = new ArrayList<SelectItem>();
Integer theValue = ...;
String theLabel = ...;
newList.add(new SelectItem(theValue.toString(), theLabel));
}
而在ActionBean类中,此列表最终将通过Spring依赖项注入到达托管beanfooVo
:
@ManagedBean(name="theAction")
@SessionScoped
public class ActionBean {
@ManagedProperty(value="#{fooVo}")
private FooVo fooVo;
public void setTheBo(IBoc theBo) {
this.theBoc = theBo;
this.FooVo.setFooList(theBo.processFooList());
}
}
我在setter Spring DI期间填写
fooVo
的愚人列表,因为我希望愚人列表
在页面加载时准备就绪。如何填写愚人列表
属性?通过设置愚人列表
的setter方法。我的意思是如何在愚人列表
中添加项目:愚人添加(new SelectItem())
或类似的内容。@LuiggiMendoza我已经在愚人节上更新了详细执行情况。
@ManagedBean(name="theAction")
@SessionScoped
public class ActionBean {
@ManagedProperty(value="#{fooVo}")
private FooVo fooVo;
public void setTheBo(IBoc theBo) {
this.theBoc = theBo;
this.FooVo.setFooList(theBo.processFooList());
}
}