Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

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

This is not working for me:

<h:form id="wfMgtForm"> 
    .
    .
    .
    <p:dataTable id="wfTable" ..." var="item">
        <p:column>
        .
        .
        .
        </p:column>
        <p:column>
            <p:commandLink id="editWatchfolderButtonId" oncomplete="dlgEditWF.show()" update=":editWFForm" process="@none">
                <f:param value="#{item.value.ID}" name="editId"/>
                <h:graphicImage alt="Edit Image" style="border: none" value="./images/edit.png" />
            </p:commandLink>
        </p:column>
    .
    .
    .
    <p:blockUI block=":wfMgtForm" trigger="editWatchfolderButtonId">
        Loading...<br/>
        <p:graphicImage alt="Loader Image" value="/images/loader.gif"/>
    </p:blockUI>
</h:form>

The error that I am getting is:

Cannot find component with identifier "editWatchfolderButtonId".

When I used Firebug to look for the ID, I discovered that every row has a different ID:

wfMgtForm:wfTable:0:editWatchfolderButtonId wfMgtForm:wfTable:1:editWatchfolderButtonId wfMgtForm:wfTable:2:editWatchfolderButtonId wfMgtForm:wfTable:3:editWatchfolderButtonId
etc.

How should I reference this auto created IDs from my <p:blockUI>?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...