我正在尝试创建一个在每一行都有一个 selectBooleanCheckbox 的 h:datatable,因此我将 dataTable 包装在一个 h:form 元素中。我的 dataTable 还需要支持分页和搜索。这工作正常,直到我将表格包装在 h:form 中,此时所有用于分页和搜索的 JQuery 元素都消失了。我将整个表格包装在一个表格中,而不仅仅是一列,因为页面上有提交按钮需要包装在与表格相同的表格中(据我所知)。
这是我的 xhtml :
<h:form>
<h:dataTable value="#{bean.tableProperties()}"
var="property" styleClass="responsive small-table"
id="propertiesSelect">
<h:column headerClass="column10">
<f:facet name="header">Properties</f:facet>
<div class="medium-12 columns checkbox" align="right">
<h:selectBooleanCheckbox id="propertySelect"
value="#{bean.selectedProperties[property.propertyId]}">
</h:selectBooleanCheckbox>
<h:outputLabel for="propertySelect" class="">
<h:outputText value=""/>
</h:outputLabel>
</div>
</h:column>
<h:column headerClass="">
<f:facet name="header"></f:facet>
<span class="">
<c:if test="#{property.name != null}">
<span class="">#{property.name}</span>,
</c:if>
</span>
</h:column>
</h:dataTable>
<div class="row actions">
<div class="medium-6 columns">
<h:commandButton class="button radius secondary small expand cancel"
value="#{localization['global.button.cancel']}"
action="#{bean.exit}" immediate="true"/>
</div>
<div class="medium-6 columns">
<h:commandButton class="button radius small expand"
value="#{localization['global.button.continue']}"
action="#{bean.submit()}"/>
</div>
</div>
<f:event listener="#{bean.validateProperties}" type="postValidate" param=""/>
</h:form>
</div>
</div>
这是JQuery:
$(document).ready(function() {
$("#propertiesSelect").DataTable({
searching: true,
"aLengthMenu": [
[5, 10, 15, -1],
[5, 10, 15, "All"]
],
"iDisplayLength": 10,
"bLengthChange": true,
"bPaginate": true,
"bSort": true,
"bInfo": true
});
});
因此,如果我删除表单,JQuery 会起作用,但 selectBooleanCheckboxes 和 commandButtons 不会,反之亦然。
我怎样才能做到这两点?