【发布时间】:2013-04-29 00:49:16
【问题描述】:
<h:selectManyListbox id="sectorsListBox" size="2" multiple="multiple" value="#{Mybean.classificationSelectedItems}">
<f:selectItems id="sectors" value="#{Mybean.classificationSelectItems}"/>
</h:selectManyListbox>
Backing Bean 有:
public class Mybean
{
private Map<String,String> classificationSelectItems = new LinkedHashMap<String,String>();
private List<String> classificationSelectedItems = new ArrayList<String>();
//getter and setter for both.
}
init()
{
classificationSelectItems.put("INS","Insurance")
classificationSelectItems.put("HLC","HealthCare")
}
多选框使用这 2 个值初始化,但问题是只有最后选择的条目存储在分类选择项中。为什么呢 ?以及如何获取存储在 classificationSelectedItems 列表中的所有选定条目?
添加仅供参考,init方法是Spring类。
【问题讨论】:
-
我刚刚用示例进行了测试,它工作正常(我使用 List alter String[]):mkyong.com/jsf2/jsf-2-multiple-select-listbox-example
-
如果您同时选择保险和医疗保健,是否都在您的分类选择项目中进行设置?
-
能贴出代码吗?
-
当然,他们两个。
标签: jsf