7

I have some code here:

<f:view>
    <h:form id="formA">
        <p:treeTable id="tree">
            <p:ajax event="select" listener="..." update="mustRefresh" />  
            ...
        </p:treeTable>
    </h:form>
    <h:form id="formB">
        <p:panel id="mustRefresh"> ... </p:panel>

    </h:form>   
</f:view>

When user select a record on treeTable(formA), its detail will show on formB and ready to edit. My trouble is update="mustRefresh" not work, it throw exception like this:

javax.faces.FacesException: Cannot find component with identifier "mustRefresh" referenced from "A4578:formA:tree". 

I tried with @form, formB, :formB and :mustRefresh but it does not work.

Chris Missal
  • 5,987
  • 3
  • 28
  • 46
user1487380
  • 362
  • 2
  • 9
  • 26

2 Answers2

24

Since mustRefresh in the component hierarchy is inside formB you should reference it with:

<p:ajax event="select" listener="..." update=":formB:mustRefresh" />

See how UIComponentBase.findComponent works.

Akos K
  • 7,071
  • 3
  • 33
  • 46
  • 2
    What if mustRefresh is not inside of formB? In my case, I should not to put mustRefresh component inside a Form element. I am calling it as `update=":mustRefresh"`, however it cannot find and refresh element. – efirat Feb 23 '16 at 21:01
17

Use update="@([id$=mustRefresh])" -- this will pick up displayPost directly. There is no need to map it to anything.

josliber
  • 43,891
  • 12
  • 98
  • 133
Mahendra
  • 177
  • 1
  • 6