【发布时间】:2016-08-24 04:16:39
【问题描述】:
我在 rich:dataTable 中有复选框列表,我想使用标题列中的一个复选框一次选中所有复选框。
<rich:column id="includeInWHMapping" >
<f:facet name="header">
<h:selectBooleanCheckbox value="#{checkallbox.selectAll}">
<f:ajax actionListener="#{checkallbox.selectAllBox}" render="selectedForWHProcess" />
</h:selectBooleanCheckbox>
</f:facet>
<h:selectBooleanCheckbox id="selectedForWHProcess" value="#{checkallbox.checked[data]}">
<f:ajax actionListener="#{checkallbox.selectAllRows}"/>
</h:selectBooleanCheckbox></rich:column>
checkallbox Bean 中的代码:
private Map<StandardStructure, Boolean> checked = new HashMap<StandardStructure, Boolean>();
private boolean selectAll;
public boolean isSelectAll() {
return selectAll;
}
public void setSelectAll(boolean selectAll) {
this.selectAll = selectAll;
}
public Map<StandardStructure, Boolean> getChecked() {
return checked;
}
public void setChecked(Map<StandardStructure, Boolean> checked) {
this.checked = checked;
}
public void selectAllBox(ValueChangeEvent e){
boolean newSelectAll = (Boolean) e.getNewValue();
Iterator<StandardStructure> keys = checked.keySet().iterator();
while(keys.hasNext()){
StandardStructure ss = keys.next();
checked.put(ss, newSelectAll);
}
}
当我检查标题列的 h:selectBooleanCheckBox 时,没有任何反应。我在这里想念什么?我是否也必须为“selectAll”属性实现 Map?
谢谢。
【问题讨论】:
-
selectAllBox被解雇了吗?您是否尝试渲染整个表格? -
@EmilSierżęga 是的,它被解雇了,但在复选框列表中没有看到这样的变化。我没有渲染整个表格,而是渲染了复选框列。感谢您的回复!
-
你必须渲染整个表格。你不能只渲染“一列”。在呈现的 HTML 中没有这样的东西一列,所以你不想呈现几个
<TD>的 id 像tableId:_NUMBER_:selectedForWHProcess。阅读这两个主题:stackoverflow.com/questions/6706849/… 和 stackoverflow.com/questions/16043218/… -
@EmilSierżęga 嘿,谢谢!但是我该怎么做呢?我是JSF的新手。对不起! :)
-
你为什么不想尝试渲染整个表格?
标签: checkbox richfaces jsf-2.2