Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF updating a composite component

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" />
like image 922
Ariod Avatar asked Mar 15 '12 19:03

Ariod


1 Answers

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.

like image 126
Matt Handy Avatar answered Nov 05 '22 04:11

Matt Handy