我的 jsf 中的两个主要组件是 p:tree 和 p:dataTable
这个想法是根据树节点选择创建一个表。
杰夫:
<h:panelGrid columns="2" style="width: 100%" columnClasses="treeColumn,tableColumn">
<h:panelGroup id="treePanel">
<p:tree id="tree"
value="#{genRepBean.root}"
var="node"
dynamic="true"
cache="true"
animate="true"
selectionMode="single"
selection="#{genRepBean.selectedNode}"
rendered="#{genRepBean.renderTree}">
<p:ajax event="select" listener="#{genRepBean.onNodeSelect}" update=":mainForm:tablePanel"/>
<p:treeNode expandedIcon="ui-icon-folder-open"
collapsedIcon="ui-icon-folder-collapsed">
<h:outputText value="#{node.name}" styleClass="tableTreeText"/>
</p:treeNode>
<p:treeNode type="au" icon="ui-icon-document">
<h:outputText value="#{node.name}" />
</p:treeNode>
</p:tree>
</h:panelGroup>
<h:panelGroup id="tablePanel">
<p:dataTable id="acqDataTable"
var="acq"
value="#{genRepBean.acqList}"
rendered="#{genRepBean.renderTable}"
filteredValue="#{genRepBean.filteredAcqList}"
paginator="true"
paginatorPosition="bottom"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15"
rows="10"
lazy="false"
style="width: 100%">
<p:column headerText="ID" sortBy="#{acq.Id}" styleClass="tableTreeText">
<h:outputText value="#{acq.Id}" />
</p:column>
<p:column headerText="IP ADDRESS" sortBy="#{acq.ipAddress}" styleClass="tableTreeText">
<h:outputText value="#{acq.ipAddress}"/>
</p:column>
<p:column headerText="STEP" sortBy="#{acq.Step}" filterBy="#{acq.Step}" filterMatchMode="contains" styleClass="tableTreeText">
<h:outputText value="#{acq.Step}"/>
</p:column>
<p:column headerText="STATUS" sortBy="#{acq.status}" filterBy="#{acq.status}" styleClass="tableTreeText">
<h:outputText value="#{acq.status}"/>
</p:column>
</p:dataTable>
bean(onNodeSelect):
public void onNodeSelect() {
acqList.clear();
this.acqList = AcqHelper.getAllViaStartDate(new java.sql.Date(startDate.getTime()));
if (!acqList.isEmpty()) {
DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("mainForm:acqDataTable");
dataTable.reset();
renderTable = true;
}
我不想删除过滤器选项,因为它对客户端非常有用,但我不知道为什么它会阻止表刷新?
任何帮助都会很棒
谢谢