1 Reply Latest reply on Dec 11, 2007 11:01 AM by pankaj.ghosh

    ModalPanel with dynamically rendered a4j:include using rende

    mtaal

      Hi,
      I try to create a modalpanel with a a4j:include which is conditionally rendered. The modalpanel is opened when a link is clicked and at that point the a4j:include should be rendered.
      The reason that it should be rendered then is that I noticed that the a4j:include is also rendered when the modalpanel is hidden (when the whole page is displayed) and this results in an error (because not all information in backing beans is set at that time).
      Another reason for dynamic rendering of the a4j:include is that then I can pass the viewid as a parameter.

      My problem is that the a4j:include is not rendered, I also tried it with a simple output text and is was neither rendered. I checked and the rendered property is true (at least the backing bean has the value true).

      I use seam 2.0 and the 3.1.3 snapshot of saturday.

      Here is the model panel code:

       <rich:modalPanel id="SearchBookAuthor">
       <f:facet name="header">
       <h:outputText value="Test" />
       </f:facet>
       <f:facet name="controls">
       <h:graphicImage value="/gfx/close.png" style="cursor:pointer"
       onclick="Richfaces.hideModalPanel('SearchBookAuthor')" />
       </f:facet>
       <a4j:outputPanel id="SearchBookAuthorPanel">
       <a4j:outputPanel id="outputPanel" rendered="#{entityHome.isShowModalPanel('BookAuthor')}">
       <a4j:include viewId="/pages/library/WriterSelect.xhtml"/>
       </a4j:outputPanel>
       <h:outputText value="TEST ME" />
       <h:outputText value="TEST ME2" rendered="#{entityHome.isShowModalPanel('BookAuthor')}"/>
       </a4j:outputPanel>
       </rich:modalPanel>
      


      And here is the code to open the modal panel:

      <h:outputLink id="SearchBookAuthorLink"
       rendered="#{entityHome.formMode!='delete'}">
       <h:graphicImage value="/gfx/search.gif" />
       </h:outputLink>
      
       <a4j:support event="onclick" limitToList="true"
       ajaxSingle="true"
       reRender="SearchBookAuthorPanel" disableDefault="true"
       rendered="#{entityHome.formMode!='delete'}"
       oncomplete="javascript:Richfaces.showModalPanel('SearchBookAuthor', {uri:'/pages/library/WriterSelect.xhtml'});">
       <a4j:actionparam name="modalPanelName" value="BookAuthor"
       assignTo="#{entityHome.showModalPanel}" />
       <a4j:actionparam name="entityName" value="Writer"
       assignTo="#{entityList.entityName}" />
       <a4j:actionparam name="maxResults" value="15"
       assignTo="#{entityList.maxResults}" />
       </a4j:support>
      


      Thanks for any help on this.

      gr. Martin

        • 1. Re: ModalPanel with dynamically rendered a4j:include using r
          pankaj.ghosh

          Hi,

          I am not sure that u can pass the view id on include tag as a parameter, so that it loads the page at runtime.
          If a parent page contains a modal panel, which has an include tag(with view id to some other page), as soon as the parent page is rendered so is the page in the include tag of modal panel.
          (I would love to see the code if this can be accomplished)
          Though if u disable the modal panel with rendered="false", it wont load the included page. :-)

          I am using the same functionality. Here is the way:

          Let the modal panel, first, be rendered with empty values.
          I think you have a button which does some server side action and populates the modal panel contents. Make this an ajax button, which calls that action. reRender the modal's output panel( in your case "SearchBookAuthorPanel") and then On 'oncomplete' show the modal panel.

          Works fine for me.

          Hope it helps,
          Pankaj