5 Replies Latest reply on Jun 6, 2007 1:51 PM by shlang

    How to rerender?

    shlang

      In the page i have following code:

      <a4j:form id="voteForm">
      <a4j:commandLink immediate="true" rendered="#{Video.mayVote}"
       id="voteButton" limitToList="true" reRender="voteButton, voteImageDisabled" actionListener="#{Video.addVote}">
      <h:graphicImage id="voteImage" url="img/votenow.gif"/>
      <f:param name="video" value="#{Video.ids}"/>
      </a4j:commandLink>
      <h:graphicImage id="voteImageDisabled" rendered="#{!Video.mayVote}" url="img/votenow_d.gif"/>
      </a4j:form>
      


      After invoking actionListener method Video.mayVote() will return false. So link must disappear and image must be displayed. But nothing changed.
      Can anybody explain what is wrong?

        • 1. Re: How to rerender?
          ilya_shaikovsky

          You may not reRender components based on rendered attribute. Wrap it to something which is present in tree always (outputPanel with none layout) and then reRender wrapper.

          • 2. Re: How to rerender?

            Key rule - do not point with reRender to the id of the component that has 'rendered' attribute. You did it twice. To minimize the changes you can each of the rerendered component with a4j:outputPanel layout="none"

            • 3. Re: How to rerender?
              shlang

              no luck...

              <a4j:form id="voteForm">
              <a4j:outputPanel id="votePanel" layout="none">
              <a4j:commandLink immediate="true" rendered="#{Video.mayVote}"
               id="voteButton" limitToList="true" reRender="votePanel" actionListener="#{Video.addVote}">
              <h:graphicImage id="voteImage" url="img/votenow.gif"/>
              <f:param name="video" value="#{Video.ids}"/>
              </a4j:commandLink>
              <h:graphicImage id="voteImageDisabled" rendered="#{!Video.mayVote}" url="img/votenow_d.gif"/>
              </a4j:outputPanel>
              </a4j:form>


              • 4. Re: How to rerender?

                in case of layout="none" you should NOT point to id of outputPanel, but to the child component. (in case of inline or block you should)

                • 5. Re: How to rerender?
                  shlang

                  Thanks a lot! Problem resolved.