1

Example:

<h:form>
  <h:commandLink action="#{someBean.someAction}">
    <f:ajax render="somePanel"/>
  </h:commandLink>
  <h:panelGroup id="somePanel">
    <h:commandLink action="#{someBean.otherAction}">
      <f:ajax render="otherPanel">
    </h:commandLink>
    <h:panelGroup id="otherPanel">
       some content here
    </h:panelGroup>
  </h:panelGroup>
</h:form>

Obviously, I am asking because I couldn't make this work. The nested commandLink is utterly dead.

Deroude
  • 1,052
  • 9
  • 24
  • I don't know how the posted code even results in a valid HTML page; you should have got an error message stating ` contains an unknown id ...`. The `render` attribute requires that all components referenced be present in the same form. See @BalusC's answer. – Vineet Reynolds Aug 26 '11 at 12:46
  • You're right, I edited the question accordingly. This is not the issue. I was trying to synthesize the issue: when i remove the first "f:ajax", the second commandLink works. With both commandLinks containing ajax, the second doesn't work for some reason. – Deroude Aug 26 '11 at 13:12
  • I don't know how you can make that claim; it works for me. Can you post code that can reproduce this issue? I've added content to the links in my work space, and have also changed the content of the panelgroup, so I think the problem is with something particular to your facelet. – Vineet Reynolds Aug 26 '11 at 13:22
  • Thanks everyone! I worked around the problem eventually. Particular thanks to BalusC for the list of causes, I'll keep it in mind (and in the bookmark list). Cheers, Vineet - peace! :D – Deroude Aug 27 '11 at 17:16

2 Answers2

1

It looks fine. It will fail when you've actually a rendered attribute set on the link or one of its parents and the bean is in request scope. This should work if the bean is put in the view scope and you always return null or void from link actions which should return to the same view. This way the conditions for the rendered attribute will be preserved. JSF namely rechecks this condition during apply request values phase of the form submit as part of safeguard against hacked/tampered requests.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0

i think first command link should be inside h:form

halil
  • 1,789
  • 15
  • 18