3 Replies Latest reply on Sep 24, 2008 8:03 AM by Ilya Shaikovsky

    link components lose their children on ajax reRender

    Troy Tarrrant Newbie


      I couldn't work this out, so hopefully someone can help me :)

      If I have a link tag with children (specifically a div) and an ajax poll that reRenders the outputPanel with which the link is inside of then the reRender does not render the div inside of the link which breaks the anchor. If I put a span it works.

      <a4j:outputPanel id="recentlyUpdatedCandidates">
       <a4j:poll action="#{viewCandidate.getNextCandidates(recentCandidateItem.index)}" reRender="recentlyUpdatedCandidates" interval="5000" />
       <a4j:repeat value="#{recentCandidateItem.candidates}" var="candidate">
       <s:link id="myLink" view="/candidateView.xhtml">
       <s:fragment rendered="#{candidate.hasImage()}">
       ... render the photo
       <div styleClass="noCandidatePhoto" rendered="#{!candidate.hasImage()}">No Photo</div>

      Now the reRendered html (after a 5 sec poll in this case) when there is a no photo condition puts the div outside of the link so you get something like

      <a href="..." />
      <div class="noCandidatePhoto">No Photo</div>

      so the link is now broken because it doesn't enclose anything. However if you replace the div with a span then you get the span enclosed inside the link so it still works.

      Can anyone explain what is happening and how can I get div's enclosed in a link on a reRender with conditional rendering?