0

Before you mark this as duplicate, I read this post from BalusC but I could not find my answer. I also tried p:component() to reference my component.

My use case is really simple:

A commandButton on one page should update a dataTable on another page.

My caller page:

<h:body>
    <h:form id="sendtxform">
                <h:commandButton id="sendtx" value="Send">
            <f:ajax listener='#{transactionXmlController.sendTx()}'
                render=":alltxform:tablealltx"/>
        </h:commandButton>
    </h:form>
</h:body>

My called page:

<h:body>

<!-- Fill the table before rendering -->
<f:event type="preRenderView" listener="#{transactionListController.findAllTx()}" />

    <h:form id="alltxform">
        <p:dataTable id="tablealltx" var="transaction"
            value="#{transactionListModel.txList}" paginator="true" rows="30">
            <!-- content -->
        </p:dataTable>
    </h:form>
</h:body>
</html>

I am getting this error:

contains an unknown id ':alltxform:tablealltx' - cannot locate it in the context of the component sendtx

How on earth do I reference my tablealltx ? I tried with and without the heading colon, and with p:component('tablealltx') What am I doing wrong ?

Community
  • 1
  • 1
Tim
  • 3,910
  • 8
  • 45
  • 80
  • Have you tried to update your wrapper `alltxform` instead of `tablealltx`? – chaeschuechli Jul 18 '16 at 12:33
  • Just tried. Same error. But I want to update the dataTable, why would I try to update its container ? – Tim Jul 18 '16 at 12:37
  • Because, as far as I know, the inner elemets will be updated as well. Have you tried to update the componente by ? Also, try to update the component by backing bean: `RequestContext.getCurrentInstance().update("foo:bar");` – chaeschuechli Jul 18 '16 at 12:42
  • But it should work without. I have not tried that yet. I would like to understand where my error is. – Tim Jul 18 '16 at 12:47
  • 1
    Obviously you use Primefaces. Why don't you use the `update` function on your `commandButton`? Not sure how f:ajax works in this context. – chaeschuechli Jul 18 '16 at 12:54
  • Well, that worked. But I am puzzled. This means the name resolution is not the same for update and render ? Or is render exclusively for elements that are on the same page ? – Tim Jul 18 '16 at 13:05
  • This seems like a legit answer but no garantue. I think this is worth an own question :) glad that it works now! – chaeschuechli Jul 18 '16 at 13:27
  • It are two completely separate pages and not a single page? Basically, you're sending a redirect from one to other page? In other words, a full page reload occurs? In that case the whole `render` and `update` stuff is unnecessary and you can simply remove it. – BalusC Jul 18 '16 at 13:29
  • @BalusC Do you have any idea why Primefaces update works and f:ajax render doesn't? Is it because there are two different pages? – chaeschuechli Jul 18 '16 at 13:34
  • Because it doesn't throw an exception anymore in more recent versions. In other words, it's silently ignored. You could as good just remove it. – BalusC Jul 18 '16 at 13:35
  • My question came from here: http://stackoverflow.com/questions/38396575/jsf-primefaces-update-a-datatable-open-in-another-tab for which I still don't have a god answer. This one can be closed I guess. – Tim Jul 18 '16 at 13:37

0 Answers0