zk and multiple browser tab

asked 2013-03-18 17:25:27 +0800

ymao gravatar image ymao

We developed our application with ZK and we use Session to pass some variables across different pages. We run into problem when user tries to use the application from multiple browser tabs. The data we stored in the session got messed up because it's the same session from different browser tabs. Any suggestions how to handle this situation?

Also could someone explains how ZK map its object model at multiple browser tab case? Do we get multiple desktops in the same session? Is there a "session" bound to a browser tab?


delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-26 09:51:16 +0800

benbai gravatar image benbai
2228 6

updated 2013-03-26 12:39:38 +0800

There is only one session for all tabs and each tab has different desktop, you can check it by the sample below:

<zk xmlns:w="client">
    <textbox id="tbx" rows="6" width="300px" />
    <button label="test">
        <attribute name="onClick"><![CDATA[
            tbx.setValue("desktop: " + self.getDesktop() + 
                    "\n\nsession: " + Sessions.getCurrent().getNativeSession());

Regarding your issue, there are several possible ways to go:

1. Store data with some UNIQUE ids, e.g., Session.setAttribute("USER_NAME", userName); This way you will always keep only one instance of specific data in session.

2. Pass variables by Execution (request scope), e.g., Executions.getCurrent().setAttribute(...) This way those data will only exists while making a request.

3. Handle some specific class (e.g., a map) to store data your self.

4. Avoid opening multiple tabs, I've done a simple sample:

full project at github

article at my blog

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2013-03-18 17:25:27 +0800

Seen: 60 times

Last updated: Mar 26 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More