8 Replies Latest reply on Jan 12, 2010 2:28 PM by Yasir Qureshi

    rich:modalPanel popup from class

    Yasir Qureshi Newbie

      I want to popup a rich:modalPanel from java class. Has anyone done it?

       

      What I am trying to do is, I am running a thread in the background that is going to check for user session timeout, 2 minutes before session expries, I want to open a modalPanel letting user know that session is about to exprie and display a timer that start from 2 miutes down to zero.

       

      Thanks!

        • 1. Re: rich:modalPanel popup from class
          Ilya Shaikovsky Master

          in general to show the panel according to some server side actions you should use showWhenRendered attribute pointed to some boolean property in the bean. When need - you setting it to true and reRender modal panel.

          • 2. Re: rich:modalPanel popup from class
            Juan Gonzalez Newbie

            I've used jquery countdown plugin succesfully, and making a rich:modalPanel appear when countdown is completed (see countdown plugin documentation to see how to execute javascript when countdown finish).

            • 3. Re: rich:modalPanel popup from class
              Yasir Qureshi Newbie

              Thanks to both of you for your replies. I think I am thinking too hard on this, solution might be easy.

               

              As far as my I know, there is no server side 'event' that tells the client that session is about to expire, there is an HttpSessionListener interface but that only provide events for session creation and expiration. The only solution I can think of is to use javascript timer (setTimeOut) and run it for the duration of sessiontime out set in web.xml - few minutes, and show a popup, if user clicks on OK it will just simply hit current page which is going to reset session inactivity and user can continue with his session. I have no idea how to determine session 'inactivity' in javascript.

               

              Ilya: By server side event do you mean running a Thread in backing bean with predetermined time and opening a modalPanel based on thread timing out? I am not aware of any event Servlet or JSF API provides for pre session expiration event.

               

              Juan: I can't use jQuery, have to stuck with technologies I currently have, and jQuery is not one of those.

               

              Any other ideas....

               

              Thanks to All,

              Yasir.

              • 4. Re: rich:modalPanel popup from class
                Yasir Qureshi Newbie

                Is there a way to call a method on backing bean when I close modalPanel from javascript?

                 

                I am executing something like this from javascript javascript:RichFaces.hideModalPanel('somePanel') and I want to execute a method in backing bean after/before the modalPanel closes.

                • 6. Re: rich:modalPanel popup from class
                  Yasir Qureshi Newbie

                  Thanks for the link Ilya, my requirements are little different from the example. In my case user does not have to click on 'OK' button on modalPanel, it is rather a javascript timer that will close the modalPanel after certian time and I want to execute a mehod on backing bean when that happens.

                   

                  I found out I can use #{myBean.property} in javascript directly, I won't be able to invoke method directly on bean but accessing property will invoke the getter method. I will write logic in getter method of the bean.

                   

                  In my case I want to show a modal panel and after some inactivity javascript timer will runout and closes the panel. When the panel closes I will access  #{myBean.logoutProperty} which is a property on bean rather than a method but accessing it will call getLogoutPropery() method in which i will do session.invalidate.

                   

                  Thanks,

                  Yasir.

                  • 7. Re: rich:modalPanel popup from class
                    Ilya Shaikovsky Master
                    use a4j:jsFunction component
                    • 8. Re: rich:modalPanel popup from class
                      Yasir Qureshi Newbie

                      Great!!! that will make code more readable. I want to show a counter on modalPanel that will start from 2:00 minutes and down to 0. On zero I will close the modalPanel and execute the a4j:jsFunction. Any idea about that? I do not have luxury of using jQuery.

                       

                      Thanks again!