Details

Description

A typical JSF-2 application contains much more GET links than we used to see in JSF-1. Thus we have far more href link to cope with.

With a classical approach we would not be able to simply add a windowId parameter to such links because if the user would open the link in a new browser window or tab, we would carry the windowId - and thus the window scope - over to the new browser tab/window.
There is a method to prevent this problem by storing a value directly in the browser window via JavaScript. Usually this is done in the same page and gets executed in the onLoadEvent like described in Marios old Orchestra summary. See "Post render window detection" in http://myfaces.apache.org/orchestra/myfaces-orchestra-core/multiwindow.html
The major downside of this solution is that we might already pollute 'foreign' beans (and destroy their information) while rendering the page.

Our new approach now works around this issue by introducing a small static new html window which gets served via a small servlet (Jsf2WindowHandlerServlet). It gets an 'url' and after detecting a new window it will drop the windowId parameter via JavaScript on the client and forwards to the destination page. For creating the destination link I'll override the encodeBookmarkableURL in an ExternalContextWrapper.

Activity

TODO:
a.) make the resource path for the windowhandler.html configurable to allow different backgroundcolors and other stuff
b.) think about caching strategies for the windowhandler.html for high-load scenarios.

Mark Struberg
added a comment - 18/Nov/10 23:27 initial funkctionality committed.
TODO:
a.) make the resource path for the windowhandler.html configurable to allow different backgroundcolors and other stuff
b.) think about caching strategies for the windowhandler.html for high-load scenarios.

Jakob Korherr
added a comment - 19/Nov/10 10:05 What about using window.location.replace() (see [1] ) instead of window.location.href in windowhandler.xhtml? This would remove the history-entry of windowhandler.html in the browser!
[1] http://de.selfhtml.org/javascript/objekte/location.htm#replace

Jakob Korherr
added a comment - 03/Dec/10 17:08 ClientSideWindowHandler works perfectly if JavaScript is enabled. Furthermore there is a fallback to the default algorithm (request parameter) if JavaScript is disabled.
Resolving this one!