JSF обновляет составной компонент - PullRequest
5 голосов
/ 15 марта 2012

Можно ли обновить дочерние компоненты составного компонента, просто указав родительский составной идентификатор?Например, если у меня есть:

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

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

</composite:implementation>

и использовать его как-то так:

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

...

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

Возможно ли это?Прямо сейчас единственный способ, которым я вижу, - явно указать идентификатор дочернего компонента:

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

1 Ответ

15 голосов
/ 16 марта 2012

Это можно сделать, обернув <div> вокруг реализации составных компонентов и установив div'ы id=#{cc.clientId}:

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

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

И на странице использования:

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

<p:ajax> должен работать соответственно.

...