Jsf 预选h中的项目:选择多个复选框
如何预选Jsf 预选h中的项目:选择多个复选框,jsf,jsf-2,Jsf,Jsf 2,如何预选h:selectManyCheckbox组件中的元素?我已经搜索了f:selectItem标记的属性,但还没有找到如何预先选择该项(即,当调用站点时,它已经被勾选)。h:selectManyCheckbox的值属性可以接受托管bean中的字符串数组。当托管bean初始化时,您可以直接为该数组设置默认值 例如,在视图中: <h:selectManyCheckbox value="#{MBean.choice}"> <f:selectItem itemValue="
h:selectManyCheckbox
组件中的元素?我已经搜索了f:selectItem
标记的属性,但还没有找到如何预先选择该项(即,当调用站点时,它已经被勾选)。h:selectManyCheckbox的值
属性可以接受托管bean中的字符串数组。当托管bean初始化时,您可以直接为该数组设置默认值
例如,在视图中:
<h:selectManyCheckbox value="#{MBean.choice}">
<f:selectItem itemValue="A" itemLabel="Choice A" />
<f:selectItem itemValue="B" itemLabel="Choice B" />
<f:selectItem itemValue="C" itemLabel="Choice C"/>
<f:selectItem itemValue="D" itemLabel="Choice D" />
</h:selectManyCheckbox>
添加到支持列表或数组中,当比较与要预选的SelectItems的值相等时返回true的对象。列表也受支持。感谢您的回答。我一直在寻找类似于SELECTED
属性的东西,但可以肯定的是,这是实现这一点的方法。我看不见森林,被所有的树遮住了眼睛。
public class MBean{
//Preselect the "Choice A" and "Choice C"
private String[] choice= {"A","C"};
//Getter and setter of choice
}