6 Replies Latest reply on Sep 12, 2008 1:54 AM by littleprince

    How to show a modal panel after actionlistener?

    littleprince

      Hi all,
      my problem is as below.
      i want to populate some data inside a modal panel.
      so i want to call actionlistener before onclick on modal panel.

      <h:commandLink value="#{mydata.day}" actionListener="#{someActionToPopulateData}"
       onclick="Richfaces.showModalPanel('panel');"></h:commandLink>
      


      But it always call onclick before calling actionListener. How to resolve this problem?

      Thanks



        • 1. Re: How to show a modal panel after actionlistener?
          moldovan

          use oncomplete attribute instead of onclick

          • 2. Re: How to show a modal panel after actionlistener?
            littleprince

            But if let say i cannot use a4j:commandLink, and must use h:commandLink. How do i overcome this?

            • 3. Re: How to show a modal panel after actionlistener?
              moldovan

              i think, then you will have a problem!
              ------------------------------------------------------------------

              but maybe, there is a solution (for sure an ugly, but i do not have another idea):

              - push-component in jsp:

              <a4j:push id="comp_push" interval="1000" eventProducer="#{theBean.addListener}"
               reRender="comp_push" data="#{theBean.openModalPanel}"
               oncomplete="if(data == true) RichfacesshowModalPanel('themodalpanel');" />
              


              with data-attribute you should call a getMethod, which returns the the value of the variabel openModalPanel...

              ...and in java-class, you can define push-listener. Call onEvent() of Pushlistener and set openModalPanel to true at the of the actionListener:

              PushListener:
              PushEventListener listener;
              
              public void addListener(EventListener listener)
              {
               synchronized (listener)
               {
               if (this.listener != listener)
               this.listener = (PushEventListener) listener;
               }
              }
              


              at the end of your actionlistener:
              this.openModalPanel = true;
              listener.onEvent(new EventObject(this));
              


              and the get-Method of the variable openModalPanel:
              public boolean isOpenModalPanel()
              {
               if(openModalPanel == true)
               {
               openModalPanel = false;
               return true;
               }
              
               return openModalPanel;
              }
              



              Maybe, you can do it this way???

              Regards


              • 4. Re: How to show a modal panel after actionlistener?
                littleprince

                Sorry to say that, i cannot use any of the a4j tag in my app. i can only use other tag like rich: h: f: etc.

                • 5. Re: How to show a modal panel after actionlistener?
                  ilya_shaikovsky

                  ok.. there is simple and seems good for you solution..

                  Just bind showWhenRendered attribute of modalPanel to some property and set it with true value if modal should be shown after request.

                  B.t.w. it's very interesting why you could use rich components and couldn't use a4j :) All this components uses the same basic framework features.

                  • 6. Re: How to show a modal panel after actionlistener?
                    littleprince

                    it works. Thanks.
                    i couldn't use a4j tag is because for some reason, after i use a4j tag, i will have BadPadding error when i m at portlet environment.