-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi All,
I am using ZL Spreadsheet 2.3 OSE, i downloaded ZK Studio plugin and created a new ZK project and used ZK Spreadsheet to open an xlsx file. But Session Timeout message is appearing on screen again and again. I tried following
<session-config>
<timer-keep-alive>true</timer-keep-alive>
</session-config>
in my zk.xml file and following is my index.zul
<?xml version="1.0" encoding="UTF-8"?>
<window title="Hello World!!" border="normal" width="100%"
apply="org.zkoss.zssessentials.generic.composer.SpreadsheetComposer" >
<timer id="timerKeepAliveSession" repeats="true" delay="6000000"/>
<zk>
<hbox>
<button id="exportBtn" label="Export All"></button>
</hbox>
<spreadsheet id="spreadsheet"
showSheetbar="true"
src="/WEB-INF/HelloZSS.xlsx"
maxrows="200"
maxcolumns="40"
width="100%"
height="500px"
></spreadsheet>
</zk>
</window>
i tried your online demo, it was working properly without any timeout message. Please guide me out from this mess.
Thanks in advance
Regards
got a solution , but not understand the problem yet, when i was running the project from eclipse it was showing session timeout again and again, but when i deployed directly into webapps folder of tomcat it is working fine, but eclipse is also using the instance of same tomcat. Can any one explain why it is so???
You need this
package cl.zippy; import org.zkoss.zhtml.Messagebox; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.util.Composer; public class DoNothing implements Composer{ public void doAfterCompose(Component comp) throws Exception { comp.addEventListener("onTimer", new EventListener() { public void onEvent(Event event) throws Exception { //Messagebox.show("alive"); } }); } }
and
<timer id="timerKeepAliveSession" running="true" repeats="true" delay="600000" apply="cl.zippy.DoNothing"/>
Actually, if I recall correctly, you do not actually need the DoNothing code Zippy suggested.
If memory serves me, the reason you are timing out in your original configuration is because your timer delay was for 6 million ms, which I believe is 100 minutes. I know for Tomcat, the default session timeout is 30 minutes unless you override it in the web.xml. So, your zul timer delay and repeat was never reached at the 100 minute mark, but instead timed out per the default web.xml session timeout. In other words, if your server container defaults to a 30 minute timeout, then by simply changing your delay to 600000, instead of 6000000, it would take effect before your session time's out.
See your original post. You had it at 6000000. In Zippy's "fix" post, it was changed to 600000. That is what, in fact, fixed the problem. The DoNothing code indeed does nothing.
If reducing the zul timer delay does not fix it, then specify, in your web.xml a session timeout that is longer than the zul timer delay, such as:
<session-config> <session-timeout>30</session-timeout> </session-config>
The web.xml uses minutes as the value, while the zul timer delay uses ms. So, careful of the difference.
The DoNothing code was suggested by ZK only for versions 5.0.6 and earlier, just as an FYI.
Ron
One thing that hasn't been mentioned yet: you need to explicitly activate a setting in zk.xml or onTimer events will not keep the session alive.
Ron, your comments on the session timeout are definitely the core problem here, but I'm still not sure about the dummy onTimer listener.
If we look at ZK source code where the onTimer event is declared:
addClientEvent(Timer.class, Events.ON_TIMER, CE_DUPLICATE_IGNORE);
It is defined with the flag CE_DUPLICATE_IGNORE, but not with CE_IMPORTANT. If CE_IMPORTANT is not used, the client will not send events to the server if there are no listeners. This means that if the dummy listener is not used, the server will never see timer events and the session will time out.
It's possible that there's some special code for onTimer events, but to me it seems that an onTimer listener is needed.
I would refere to this link (http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/UI_Patterns/Session_Timeout_Management). The use of the timer listener is taken from documentation for 5.0.6 and earlier. The newer documentation that I cited mentions nothing of it.In fact, the only thing I have configured in my project is in zk.xml, web.xml, and then the timer in the .zul page. I don't use a timer listener, and it functions just the way I want.
Here's how I have it:
ZK.XML
<session-config> <timer-keep-alive>true</timer-keep-alive> </session-config>
WEB.XML
<session-config> <session-timeout>30</session-timeout> </session-config>
*.ZUL
<timer id="timerKeepAliveSession" repeats="true" delay="600000"/>
That's it, nothing more, and it doesn't timeout on me.
One more thing. You don't mention much about your environment. But, be aware that timeouts can exist at multiple levels: your desktop browser, your WAF (if you have one in place), the war container (Tomcat, Websphere, etc.), your PIX (again, if you have one).
Asked: 2012-05-31 07:03:51 +0800
Seen: 430 times
Last updated: Jun 05 '12