【发布时间】:2014-12-14 21:19:12
【问题描述】:
我正在尝试实现一个复选框标题以选择所有richFaces dataTable 行。 调用 setSelction 但 selection.size = 0; 支持 bean 是来自 seam 2.2.2 的 EntityHome 知道为什么未将所选行设置为选择吗?
谢谢
<h:form styleClass="association" id="heavyChainsChildren">
<rich:extendedDataTable
onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
value="#{myEntityHome.myData}"
selectionMode="multi"
selection="#{myEntityHome.selection}"
var="entry"
rendered="#{not empty myEntityHome.myData}"
rowClasses="rvgRowOne,rvgRowTwo"
id="myDataTable">
<rich:column align="center" width="150px" sortable="false">
<f:facet name="header">
<h:panelGroup style="width:150px;" layout="block">
<script type="text/javascript">
//<![CDATA[
function checkAllCheckboxesInTable(inputId, state) {
var commonIdPart = inputId.substr(0, inputId.lastIndexOf(':'));
var tableId = commonIdPart + ':tu'
var tableElement = document.getElementById(tableId);
var inputs = tableElement.getElementsByTagName('input');
for (var i = 0; i <= inputs.length; i++) {
var input = inputs[i];
if (input.getAttribute('type') == 'checkbox' && state) {
input.setAttribute('checked', state);
} else {
input.removeAttribute('checked');
}
}
}
//]]>
</script>
<h:selectBooleanCheckbox id="checkAll" title="#{bundle.CHECK_ALL}" onclick="checkAllCheckboxesInTable(this.id, this.checked);">
<a:support event="onchange" reRender="myDataTable"
/>
</h:selectBooleanCheckbox>
<h:outputText value="#{bundle.IDENTITY_CHECKBOX_SELECT_ALL}"/>
</h:panelGroup>
</f:facet>
<h:selectBooleanCheckbox id="checkEntry" value="#{entry.selected}" disabled="false"/>
</rich:column>
豆子:
@Name("myEntityHome")
public class MyEntityHome extends EntityHome<MyEntity> {
private static final Logger log = LoggerFactory.getLogger(MyEntityHome.class);
private SimpleSelection selection;
public SimpleSelection getSelection() {
log.info("getSelection called ....");
return selection;
}
public void setSelection(SimpleSelection selection) {
log.info("setSelection called ...");
this.selection = selection;
}
【问题讨论】:
-
我不确定您要做什么,选中复选框不会选中该行。
-
我想使用一个复选框来选择/取消选择rich:dataTable或extendedDataTable中的所有行
标签: java datatable richfaces seam2