在页面中有:
<h:selectManyCheckbox value="#{auser.quanx}" styleClass="bartext">
<f:selectItems value="#{auser.qxItems}"/>
</h:selectManyCheckbox>在mybean中有:
private static String[] quanx=new String[3];
private static SelectItem[] qxItems = new SelectItem[]{ new SelectItem("用户设置"), new SelectItem("栏目设置"), new SelectItem("信息上传"), };
问题是:怎样读取选择后的值? 我在代码中通过quanx[0],读取时总失败。
<h:selectManyCheckbox value="#{auser.quanx}" styleClass="bartext">
<f:selectItems value="#{auser.qxItems}"/>
</h:selectManyCheckbox>在mybean中有:
private static String[] quanx=new String[3];
private static SelectItem[] qxItems = new SelectItem[]{ new SelectItem("用户设置"), new SelectItem("栏目设置"), new SelectItem("信息上传"), };
问题是:怎样读取选择后的值? 我在代码中通过quanx[0],读取时总失败。
硬編碼的方式
<h:selectManyCheckbox value="#{auser.quanx}" styleClass="bartext">
<f:selectItem itemLabel="用户设置" itemValue="1"/> <f:selectItem itemLabel="栏目设置" itemValue="2"/> <f:selectItem itemLabel="信息上传" itemValue="3"/>
</h:selectManyCheckbox> 或者這樣,把mybean改動一下
public List<SelectItem> getTypes() {
List<SelectItem> types = new ArrayList<SelectItem>(); types.add(new SelectItem("1", "用户设置"));
types.add(new SelectItem("2", "栏目设置"));
types.add(new SelectItem("3", "信息上传")); return types;
}
应该是这样的,这样就把你的Value Set到你的SelectManyCheckBox 中了,可以从后台取得