How to reference p:commandLink in p:dataTable from p:blockUI trigger?

让人想犯罪 __ 提交于 2019-11-29 10:33:59

The <p:dataTable> is also a NamingContainer. Include its ID as well.

<p:blockUI ... trigger="wfTable:editWatchfolderButtonId">

The row index is only present in client side, not in server side, so that's not relevant.


Update: just tested it locally, it indeed fixes the exception, but it didn't trigger the block UI at all (PrimeFaces 3.5). Look like a bug in PrimeFaces.

In the meanwhile, your best bet is to manually trigger it as suggested by Aksel, but then somewhat different:

<p:commandLink ... onclick="bui.show()" oncomplete="bui.hide()">
...
<p:blockUI widgetVar="bui" />

Here is a trivial example of using commandLink to block something. Modified the showcase example from here

<h:form>
    <p:commandButton value="blockMe" id="someId" />
    <br />
    <p:commandLink id="pnlBtn" value="Block" type="button"
        onclick="bui.show()" />
    <br />
    <p:commandLink id="pnlBtn2" value="Unblock" type="button"
        onclick="bui.hide()" />

    <p:blockUI block="someId" widgetVar="bui" />
</h:form>

For those as clueless as myself, if BlockUI is not firing, check that the "trigger" target has Ajax enabled. I spent almost a day trying to figure out why BlockUI did not fire and found that I had its target configured as 'ajax="false"'.

You can use a jquery selector.

<p:commandLink styleClass="mybutton-class">
<p:blockUI ... trigger="@(.mybutton-class)">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!