Martin,

I had to modify your example to get it to work, as request.getUrl()
actually returns a new Url instance when it's called.  Here's what I
settled on:

@Override
public IRequestHandler mapRequest(Request request) {
Request requestToMap = request;
if ((request instanceof WebRequest) && !((WebRequest) request).isAjax()) {
PageComponentInfo info = getPageComponentInfo(request.getUrl());
if (info != null) {
Url url = request.getUrl();
url.removeQueryParameters(info.toString());
requestToMap = request.cloneWithUrl(url);
}
}
return super.mapRequest(requestToMap);
}

Does anyone see any issues with this approach?

Thanks!

-Allen

On Mon, Dec 5, 2011 at 2:28 PM, Martin Grigorov <mgrigo...@apache.org>wrote:

> Hi,
>
> Here is an idea (again from me:-) ):
>
> Override MountedMapper and in #mapRequest(Request) do:
>
> if (((WebRequest) request).isAjax()) return super.mapRequest(request);
>
> // else
> url = request.getUrl();
> info = getPageComponentInfo(url);
> if (info != null) url.removeQueryParam(info.toString());
>
> return super.mapRequest(request)
>
> This will cut the special parameter that brings the page info
>
> On Mon, Dec 5, 2011 at 8:08 PM, Allen Gilbert <allen.gilb...@doane.edu>
> wrote:
> > Hello,
> >
> > I have a problem similar to the one outlined here:
> >
> http://apache-wicket.1842946.n4.nabble.com/Migrating-from-1-4-16-to-1-5-RC3-problem-when-trying-to-avoid-pages-caching-not-calling-the-construc-td3463183.html
> .
> > I have a page that uses a lot of Ajax (and is thus stateful/versioned),
> but
> > I need its constructor to be called any time the page is requested.
> >  Otherwise, if the user lands on the page via the back button, it will
> not
> > be rendered correctly.  Anyway, I'm looking into creating a custom
> > IRequestMapper, per Martin's suggestion in the Nabble thread.  However, I
> > don't know where to start. Should I extend one of the existing mappers
> > (e.g. MountedMapper), or should I create an entirely new implementation
> of
> > IRequestMapper?  In either case, how do I make sure that I don't screw up
> > handling of listener links for ajax actions on the page?  In other words,
> > how do I create a reliable IRequestMapper for a page that, when
> requested,
> > always re-renders itself?
> >
> > If there's a different way to accomplish this (i.e. without creating a
> > custom IRequestMapper or making the page stateless), I'd love to know.
> >
> > Thanks for your help!
> >
> > -Allen
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to