5

Is it possible to update child components of a composite component just by specifying the parent composite ID? E.g. if I have:

<composite:interface>
    <composite:attribute name="value" type="..." required="true"/>
</composite:interface>

<composite:implementation>
    <p:treeTable id="main-tree" ...>
        ...
    </p:treeTable>

</composite:implementation>

and to use it somehow like this:

<my:comp id="composite-component" />

...

<p:ajax update="composite-component" />

Is that possible? Right now the only way I see is to specify the child component ID explicitly:

<p:ajax update="composite-component:main-tree" />
Geinmachi
  • 1,251
  • 1
  • 8
  • 20
Ariod
  • 5,757
  • 22
  • 73
  • 103

1 Answers1

15

This can be done by wrapping a <div> around your composite components implementation and set the div's id=#{cc.clientId}:

<html ...>
    <composite:interface>
       ...
    </composite:interface>

    <composite:implementation>
      <div id="#{cc.clientId}">
        ...
      </div>
    </composite:implementation>    
</html>

And in the using page:

<my:comp id="composite-component" />
....
<h:commandButton value="Update first name">
   <f:ajax execute="composite-component" render="composite-component">
</h:commandButton>

The <p:ajax>should work accordingly.

Matt Handy
  • 29,855
  • 2
  • 89
  • 112