java - Wicket - refresh component on evry Request (implementing session timeout countdown) -
i have wicket 6.10.0 web application. want implement timer display remaining time in current user session. link this: http://jsfiddle.net/justinobney/uzmgd/
i have wicket label
in footer of page. label uses javascript countdown time example 5 minutes down 0 min 0 sek. countdown (label) should refreshed on every request.
now question how this?
in init()
method added , abstractrequestcyclelistener
notifies me of every end request this:
getrequestcyclelisteners().add(new abstractrequestcyclelistener() { @override public void onendrequest(requestcycle cycle) { super.onendrequest(cycle); system.out.println("end request - here refresh somehow label"); } });
but dont know how send message label refresh itself. ideas?
* e d t : * have spa:
<body> lots of ajax components here <div wicket:id="footer">footer stays here. <br /> session timeout in: <span wicket:id="sessiontimeoutlabel">countdown here</span> </div> </body>
the countdown works little bit this: http://jsfiddle.net/justinobney/uzmgd/
now on every ajax request need sessiontimeoutlabel
label rerender start counting lets 600 seconds down 0.
don't focus on "end of request". 10µs after render phase. note session timeout reset after each request, there no need update label new value, other reset session timeout parameter.
you should have parameter somewhere dictates session timeout configured, , use show label, if application specific can create getter in application class:
public myapplication extends webapplication { public static final int session_timeout = 30; // minutes public int getsessiontimeout() { return session_timeout; } }
and in footer can add label:
add(new label("timeout", propertymodel.of(this, "application.sessiontimeout")));
or if property of session, can add getter custom session:
public mysession extends websession { public static final int session_timeout = 30; // minutes public int getsessiontimeout() { return session_timeout; } }
and retrieve in label:
add(new label("timeout", propertymodel.of(this, "session.sessiontimeout")));
the expression property models make use of fact component has getter application , getter session.
Comments
Post a Comment