Update a idleMonitor

UI Components for JSF
Post Reply
warriorshadow
Posts: 42
Joined: 12 Sep 2013, 15:34

18 May 2015, 17:03

I have a idle Monitor in my principal page, and I trying to update the idleMonitor timeout when I press a checkbox that extends the time session of my application. this is my code

Code: Select all

 <p:idleMonitor timeout="#{(session.maxInactiveInterval * 1000) - (30 * 1000) }"
                onidle="startIdleMonitor()"
                onactive="PF('timeoutDialog').hide()" 
                id="sessionTimeout"/>
for testing purpose, the sesion default is one minute and I am telling here than after 30 seconds, show a dialog that displays a message saying tha there's only 30 seconds left. this works fine, but when I set the checkbox:

Code: Select all

  <p:selectBooleanCheckbox 
             value="#{cc.attrs.bean.session_extended}"
             id="sessionExtendedCheckBox"
             styleClass="sessionCheckbox"
             >
              <p:ajax update=":#{p:component('sessionTimeout')}" 
                      listener="#{cc.attrs.bean.requestMoreSession()}" />
        </p:selectBooleanCheckbox>

the requestMoreSession method extends the session timeout, duplicating the value:

Code: Select all

public void requestMoreSession() {
        HttpSession session;
        int timeOut; 
        FacesContext fc = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
        session = request.getSession();
        if (session_extended) {
            timeOut = session.getMaxInactiveInterval();
            fc.getExternalContext().setSessionMaxInactiveInterval(timeOut*2);
        }
        else{
            if(!session_extended){
                timeOut = session.getMaxInactiveInterval();
                session.setMaxInactiveInterval(timeOut/2);

            }
        }
    }

But the ajax update is not working. The only thing to make this work is making a completely refresh of the page. There's another way to update the timeout attribute of the idle Monitor in order that this work? Something that I missing? or better way to refresh this without a completely refresh of the while page?

I really appreciate your help,
Primefaces 5.2
Apache Tomcat 7.0.34
NetBeans 7.3.1
Linux Ubuntu

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

18 May 2015, 18:26

what is your intention? I've never seen something like this. Session timeout should be 'reset' each time it is accessed and the idleMonitor even on mous-move

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 64 guests