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

    link components lose their children on ajax reRender

      Hi,

      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" />
       <ul>
       <a4j:repeat value="#{recentCandidateItem.candidates}" var="candidate">
       <li>
       <s:link id="myLink" view="/candidateView.xhtml">
       <s:fragment rendered="#{candidate.hasImage()}">
       ... render the photo
       </s:fragment>
       <div styleClass="noCandidatePhoto" rendered="#{!candidate.hasImage()}">No Photo</div>
      
       </s:link>
       </li>
       </a4j:repeat>
       </ul>
      </a4j:outputPanel>
      


      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?

      Thanks

      Troy