2

I have 2 links in a web page, link one pint to appserver/?dept=1, link two is appserver/?dept=2. Then I have a JSF phase listener, in there, I can get the back end bean and set dept1 or dept2 as the bean parameter, in order to render different department contents. If user starts 2 windows from above web page, the contents of dept1 window can go to dept2 window. All messed up. (Note, if you start browser from desk top short cut, type in above links, no problem, since 2 session will be created, 2 different back end bean instances crated).

The key reason is JSF store back bean in the session, thus 2 windows which from the same parent window shared the same session id (cookie), then used the same back end bean class instance. At render result time, the result can go to either window.

How can I avoid this window cross contents situation? This seems a fundamental web app problem that should be resolve long time ago. Or I might doing things really wrong.

I tried seam conversion, no help, JSF2.0 has view scope, CDO. dose it can help ? We can not move to JSF2.0 yet due to various reason. I am using JAVA6, Tomcat6.20, Icefaces. Any help is appropriated.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Charles
  • 161
  • 1
  • 3
  • 12

3 Answers3

2

In JSF 1.x, your best bet is Tomahawk's <t:saveState>. Just put it in the page where the specified request scoped bean is to be retained in the subsequent request which is fired by the very same page, regardless of the browser tab/window.

<t:saveState value="#{bean}" />

It acts like the JSF 2.0 view scope.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks. I will give a try. Also I was thinking, I might can change the link page to use different URL (one app server has different servlets for each department), that might can have each window create different session due to they hit different url. But problem may still there if user open multiple window in for the same department. – Charles Dec 06 '10 at 14:12
  • BalusC, you suggestion works. And I think this is the most non-intrusive and simplest solution. I got it it work in 1 hour. Just to shared the experience for others: 1. You have to define bean scope as request. 2. Make back bean code serializable. 3. I used: common-el-1.0.jar common-fileupload-1.2.1 jar, commons-io-1.3.2.jar tomahawk12-1.1.10.jar from downloaded Tomahawk lib. – Charles Dec 06 '10 at 19:48
0

your problem easily can be solved by using seam conversations, you can look at the examples come with seam package. you need to change your backing bean scope to conversation from session and use page parameters. also seam in action book explains this use case with very nice and brief examples.

  • Yes, I thought so too, I tried seam download example, only one example can run on plain Tomcat without Jboss plubin. But problem still there. I added pages.xml, annotations (like @converstion scope, @Begin etc) no help. I will looking into "seam in action" book example as you mentioned. Thanks. – Charles Dec 06 '10 at 14:06
0

Take a look at MyFaces Orchestra.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140