3 Replies Latest reply on Jul 28, 2008 10:47 PM by kukeltje.ronald.jbpm.org

    ModalPanel rerender

    ashsneider

      Hi, everyone.


      I have a dataGrid of images. When a image is clicked on, a ModalPanel containing the image appears. The modalPannel also contains two buttons 'previous' and 'next'. When a button is clicked on, i want the modalPannel to display the previous or the next image in the list respectively.


      Any help is appreciated.


      Thank you.

        • 1. Re: ModalPanel rerender
          mail.micke

          Not sure this is a good idea or works (just typed it in here) but it should get you started.


          You just need to save the current index of the image you are showing in your backing bean (which should be PAGE scoped) and increment and decrement that value.



          In the dataGrid


          <a4j:commandLink value="Show" 
          action="#{backing.setImageIndex(varItem)}" 
          reRender="theImage" 
          oncomplete="#{rich:component('modalPanel')}.show();""/>
          




          In the modal panel


          <h:graphicImage id="theImage" value="#{backing.currentImage}"/>
          
          <a4j:commandLink value="Prev" 
          action="#{backing.prevImage}" 
          reRender="theImage"/>
          <a4j:commandLink value="Next" 
          action="#{backing.nextImage}" 
          reRender="theImage"/>
          





          In the backing bean


          public void setImageIndex(final String imageStr){
             imageIndex = imageList.indexOf(imageStr);
          }
          
          public String getCurrentImage(){
          
             return imageList.get(imageIndex);
          }
          
          public void nextImage(){
             imageIndex++;
          }
          
          





          • 2. Re: ModalPanel rerender
            ashsneider

            Thank you, Mikael Andersson.


            Indeed, it helped me get started, and I managed to solve the problem.

            • 3. Re: ModalPanel rerender
              kukeltje.ronald.jbpm.org

              Would be a nice example to put in the wiki somewhere if you'd care to share it with us