Hi,
It seems to work :)
I've just made some minor tweaks (code below). One more thing.
StringResponse still doesn't encode URLs correctly. String response is
the one responsible for rendering head. So in current state, opening
link in new tab without cookies leads to session expiration :(
Now the code. I change it to render the cookies javascript even if
there's no page in page map. This is safe and leads to better behavior.
-Matej
public final void renderHead(final Response response)
{
final WebRequestCycle cycle =
(WebRequestCycle)getRequestCycle();
final IRequestTarget target = cycle.getRequestTarget();
int initialAccessStackSize = 0;
if (getApplication().getRequestCycleSettings().getRenderStrategy() ==
IRequestCycleSettings.REDIRECT_TO_RENDER
&& target instanceof
RedirectPageRequestTarget)
{
initialAccessStackSize = 1;
}
// Here is our trickery to detect whether the current
request was
// made in a new window/ tab, in which case it should
go in a
// different page map so that we don't intermangle the
history of
// those windows
final ArrayListStack accessStack =
getPageMap().getAccessStack();
//---------------------------------------------------------------------------
// it's no longer necessary to have this check here.
Cookies related
// javascript can be rendered even when there's no page
in pagemap
if (true || accessStack.size() > initialAccessStackSize)
{
CharSequence url = null;
if (target instanceof
IBookmarkablePageRequestTarget)
{
IBookmarkablePageRequestTarget current =
(IBookmarkablePageRequestTarget)target;
BookmarkablePageRequestTarget redirect = new
BookmarkablePageRequestTarget(
getSession().createAutoPageMapName(), current.getPageClass(), current
.getPageParameters());
url = cycle.urlFor(redirect);
}
else
{
url =
urlFor(INewBrowserWindowListener.INTERFACE);
}
final BodyContainer body = getBodyContainer();
final Cookie[] cookies =
cycle.getWebRequest().getCookies();
//---------------------------------
// put the check here.
if ((accessStack.size() > initialAccessStackSize && cookies == null)
|| body == null)
{
// If the browser does not support
cookies, we try to work
// with the history
...
Johan Compagner wrote:
Hi
Can somebody look if it works for him on their browser?
I changed the new window detection for a pagemap by setting in
javascript cookies (with the pagemap name as cookie name)
now on a page load we set a cookie and on a body.onUnLoad we delete the
cookie again.
So when the page is still there and another page is loaded in a new
window or tab. He first looks for the cookie
and it will see that it is there and then does redirect to another pagemap.
It will only do this if a cookie can be set (if the current request has
cookies) else it will do the previous check.
The correct working of this behaviour more or less depends on one thing.
That body.onUnLoad does get executed.
(and cookies must be able to set in javascript)
johan
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop