过滤惰性数据表后是否有可能更新其他组件?
<p:dataTable id="dataTable" value="#{NewsBean.items}" binding="#{NewsBean.items.dataTable}" lazy="true" filteredValue="#{NewsBean.filter}" var="item" paginator="true" rows="10"
currentPageReportTemplate="(Displaying results {startRecord} - {endRecord} of {totalRecords})"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,50,100,200,500,1000" filterEvent="enter">
...
<p:ajax event="filter" update="some_other_component" />
...
</p:dataTable>
<p:blockUI block="dataTable" trigger="dataTable" />
具体问题是,过滤器事件在我的 dataTable 完成延迟过滤之前触发,因此其他组件的更新事件将提前触发。因此该组件无法显示过滤器特定内容。再次过滤将显示前一步的结果。
我找到了 BalusC 的解决方案来使用远程命令。
<p:ajax event="filter" oncomplete="updateFilterSelection()" />
<p:remoteCommand name="updateFilterSelection" update="some_other_component" />
但是使用此解决方案将以无限加载我的 blockUI 告终。似乎不再触发 oncomplete 事件。
有什么解决办法吗?
我正在使用primefaces 3.5。
谢谢
编辑:我为我找到了一个按预期工作的解决方案:
<p:ajax event="filter" listener="#{some_Method}" update="some_other_component" />
some_Method 确实调用了刷新,例如对当前 View 的重定向。但我敢肯定,这会产生大量开销。
最佳答案
我遇到了类似的问题:
加载惰性数据后如何更新用户界面。
似乎没有针对此的 Primefaces 事件。
这是我的解决方案:
load()
方法:RequestContext.getCurrentInstance().execute("updateUserInterface()");
function updateUserInterface() {
// Commands to update the user interface
}
关于ajax - 如何在过滤primefaces中的惰性数据表后更新其他组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23519213/