[英]Using the page event with p:dataList in PrimeFaces
Does a <p:dataList>
support the page
event? <p:dataList>
是否支持page
事件? I'm trying to use the page
event in the following way (blocking a <p:dataList>
using <pe:blockUI>
while going through pages). 我试图以以下方式使用
page
事件(在浏览页面时使用<pe:blockUI>
阻止<p:dataList>
)。
<pe:blockUI target="dataList" widgetVar="blockDataListUIWidget">
<h:panelGrid columns="2">
<h:graphicImage library="default" name="images/ajax-loader1.gif"/>
<h:outputText value="Fetching..." class="block-ui-text"/>
</h:panelGrid>
</pe:blockUI>
<p:dataList id="dataList"
var="orderRow"
value="#{orderDetailsManagedBean}"
first="0"
rows="1"
paginator="true"
paginatorAlwaysVisible="false"
type="definition" lazy="true"
emptyMessage="Message">
<p:ajax event="page"
onstart="PF('blockDataListUIWidget').block()"
oncomplete="PF('blockDataListUIWidget').unblock()"
process="@this"
update="@none"/>
...
</p:dataList>
This does not work anymore. 这不再起作用。 The page just remains blank with no errors.
页面只是空白,没有错误。 Events don't seem to be supported by
<p:dataList>
. <p:dataList>
似乎不支持事件。
Can this scenario be simulated in <p:dataList>
anyway? 无论如何,可以在
<p:dataList>
模拟这种情况吗?
As I have seen from the source code that page
event is not supported by dataList
, on the other hand dataGrid
supports it . 从源代码中可以看出,
dataList
不支持page
事件,而dataGrid
支持它 。
The solution would be monkey patching as we don't have control on rewriting the original JS file, you can hook an event before the handling of the pagination and after it, all by javascript. 解决方案将是猴子修补,因为我们无法控制重写原始JS文件,您可以在处理分页之前和之后挂接事件,所有这些都可以通过javascript进行。
Here's an example: assuming your dataList widgetVar
is dataListWV
这是一个示例:假设您的dataList
widgetVar
是dataListWV
//making sure the widgetVar is ready to be used
setTimeout(dataListPaginationExtraEvents, 1000);
function dataListPaginationExtraEvents() {
var odlHandlePagination = PF('dataListWV').handlePagination;
PF('dataListWV').handlePagination = function(newState) {
//before
console.log('start fetch');
//calling original pagination
odlHandlePagination.apply(this, [newState]);
//after
console.log('end fetch');
}
}
As of PrimeFaces 5.3 final (community release), the page
event is supported in <p:dataList>
从PrimeFaces 5.3 final(社区版本)开始,
page
事件在<p:dataList>
受支持。
The following picture is taken from the PrimeFaces user guide 5.3 (page 146). 下图取自PrimeFaces用户指南5.3 (第146页)。
There is no mention of Ajax behavior events in previous guides. 在先前的指南中没有提及Ajax行为事件。
The page
event as mentioned in the question works flawlessly in PrimeFaces 5.3 final (community release). 问题中提到的
page
事件在PrimeFaces 5.3 final(社区发行版)中可以完美地工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.