2 Replies Latest reply on Dec 9, 2010 2:49 PM by jabailo

    a4j:poll as client side timer

    jabailo

      I want to use an a4j:poll as a client side timer.   My goal is to build a timeout warning noticewhich will display a popup, alert or some display on the JSF page -- that the server session timeout is about to be reached in 3 minutes.

       

      I want to read the interval value from a bean, then start the timer on page load.

       

      After that I want the a4j:poll to trigger a client side event, such as displaying a popup...and I do not want to trigger any calls to the server.

       

      If any action occurs on the JSF page, I want to reset the a4j:poll to a new interval.

       

      1. Does reRendering a4j:poll "reset" the interval timer?   How about disable/enable?

       

      2. Can a4j:poll trigger a client side event (like dispaying a hidden value) without making a call to the server?

       

      3. Can I set up an a4j:poll so that interval timer is reset with any page action (such as clicking on a richfaces:Datatable column sort)?

       

       

      (So far I have tried using a4j:poll server side but that has a Catch 22 of resetting the lastAccessTime and extending the session.  I have also tried implementing a4j:push but there seems to be a bug where it is not seeing events pushed to the listener.  Also, it seems like I cannot access HttpSession from a bean that implements Runnable).

        • 1. Re: a4j:poll as client side timer
          blabno

          a4j:poll is not for such purpose. It will be easier if you write your own JavaScript function and put it into setTimeout() or setInterval(). The I suggest binding two events "keydown" and "click" on document. That should trigger function that would reset the timeout or interval.

           

          Personally I think it is better not to notify user about session expiration comming soon. I assume that if user has open window then his session should be extended. To do that i have a4j:poll with interval shorter by one minute from session timeout.

          • 2. Re: a4j:poll as client side timer
            jabailo

            If the user has an open window and leaves his desk, you would not want to extend the timeout because that would create a security problem.

             

            The point of the notification is that if he is sitting at his desk and he does something else (talks on phone) for longer than the JBoss timeout, he should be notified in case he wants to keep working on his application later.

             

            I found a client side plugin to do this writen for JQuery and you are helping me in another thread (Thanks!)