But there is a difference in the way it behaves with and without the
empty-pagemap-check.
Say the check is there, and the javascript is not rendered for the first
time page is displayed. You open a link on that page in new tab and the
new tab will be in the same pagemap. Therefore I suggest to always
render the cookie javascript.
I checked it with today's svn version, and the URL was _not_ escaped. I
mean the url that goes to the rendered javascript.
Btw, wouldn't there be a way to support mounted urls also with wicket
created pagemaps?
Currently, i mount a page on /foo/bar and if I open the page in new tab,
it's no longer /foo/bar, it's bookmarkablePage=org.foo.Bar instaead.
Something like /foo/bar/p1/v1/p2/v2;wicket-pagemap=wicket-0 would be nice.
-Matej
Johan Compagner wrote:
Don't think this will do much. because for the first page render (the
homepage)
there are no cookies set yet. So it always then still does the check for
the initialpage.
But i guess if somebody in the webapp has disk cookies set we could use
the cookie
pagemap check sooner.
about the url encodig. I changed all code in the core of wicket to use
RequestCycle.getOriginalResponse()
instead of using the current response. So that the url encoding is
always done on the servlet response.
wil namespace the javascript functions.
johan
On 4/16/06, *Matej Knopp* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
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
<http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
<mailto:Wicket-develop@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
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