3 Replies Latest reply on Jun 4, 2008 4:26 PM by infinity2heaven

    rich:modalPanel, how to fire actions using onshow or onbefor

    infinity2heaven

      Richfaces: 3.2.0.CR1

      JBoss Seam 2.0.2CR1

      Facelets snippet

      <a href="#" onclick="JavaScript:Richfaces.showModalPanel('somePopup',{width:650, top:300})">
      <h:graphicImage value="./img/star_grey.gif"/></a>
      <rich:modalPanel id="somePopup" minHeight="300" minWidth="650" zindex="6000">
       <a4j:support event="onshow" action="#{myBean.retrieveSomething(bean.id)}"/>
       <f:facet name="header">
       <h:outputText value="Bean History" />
       </f:facet>
       <f:facet name="controls">
       <h:graphicImage value="./img/close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('somePopup')" />
       </f:facet>
       <ui:include src="beanHistory.xhtml" />
      </rich:modalPanel><br/>


      Instead of a4j:support event="onshow", I tried this

      <rich:modalPanel id="somePopup" minHeight="300" minWidth="650" zindex="6000" onshow="#{myBean.retrieveSomething(bean.id)}"


      It doesn't fire the action method from myBean, in fact it doesn't even recognize whatever the value is in the EL. (I tried some junk values, and it doesn't complain). All I get is a modal popup. I tried onbeforeshow, same problem. With a4j:support, it says my target is unreachable (mybean =null). That cannot be as the bean (SFSB) is very well present in page as the rest of the page is functional.

      How do I fire an action even (on a SFSB in Seam) before the modal pops up?


        • 1. Re: rich:modalPanel, how to fire actions using onshow or onb

          Hi

          onshow is the event hook and u can't do an Server action method el binding.

          probably you can do the onDemand loading to modal window.

          something like

          <a4j:commandLink action=#{somebean.action}
          reRender="modalWindowID"
          oncomplete="show modal window">

          </a4j:commandLink>

          by that way u can optimize the modal window loading.

          but i feel modal window should behave like a javascript window. open where in it should by providing an action method URL or jsf URL

          anyways this what we are doing to reduce page-size.

          • 2. Re: rich:modalPanel, how to fire actions using onshow or onb
            infinity2heaven

            awesome, this is exactly what I wanted (modal window loads very slow though, need to look into ejbql) but Thank you.

            • 3. Re: rich:modalPanel, how to fire actions using onshow or onb
              infinity2heaven

              So I'm using

              <a4j:commandLink actionListener="#{myBean.retrieveFoo(param1, param2)}"
               reRender="dataTable" ajaxSingle="true" immediate="true"
               oncomplete="JavaScript:Richfaces.showModalPanel('myPopup',{width:650, height:400, top:300})">
              <h:graphicImage value="./img/icon_warning.gif" rendered="#{!someBean.isRulesValidated}"
               title="#{someBean.ruleValidationMessages}"/>
              </a4j:commandLink>


              In all versions of Richfaces, (inc 3.2.1.GA), the behaviour for the above is not consistent.

              Sometimes, it works, ie, the action fires up and I see the modal panel with the results.

              But most times -- the action fires (as a I see in the logs) but the modal panel is empty. I have to click it like 3-4 times or refresh the page to see the modal panel

              I was trying different options like immediate="true" etc .. but no use

              Any ideas?

              I