JSF updating a composite component

做~自己de王妃 提交于 2019-12-23 10:54:33

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/9726818/jsf-updating-a-composite-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!