You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jeroen Steenbeeke <j....@gmail.com> on 2021/11/11 12:59:02 UTC

Custom error handler (IRequestCycleListener) with Bookmarkable page

Our application uses an implementation of IRequestCycleListener to redirect
users to a custom error page with contextual information (which includes a
reference to an external bug tracking system).

When the target page is also mounted in the application, we are seeing
rather unexpected behavior: the custom error page is created as expected,
but Wicket then tries to recreate the page by calling a default constructor
(which exists), rendering the error page without the contextual information.

Is this expected behavior, or is this a bug?

I've created the following quickstart to illustrate the problem:

https://github.com/jsteenbeeke/wicket-custom-mounted-errorpage-loses-context

Sincerely,

Jeroen Steenbeeke

Re: Custom error handler (IRequestCycleListener) with Bookmarkable page

Posted by Jeroen Steenbeeke <j....@gmail.com>.
Hey Bas,

First of all thanks for debugging and for your explanation.

I had to dig a bit in the Git history, but the purpose of the zero-args
constructor was to provide an entrypoint for a (now defunct) Selenium test
suite to see if the error page rendered correctly.

Either way, both of your solutions appear to work.

Sincerely,

Jeroen

Op do 11 nov. 2021 om 16:21 schreef Bas Gooren <ba...@iswd.nl>:

> Hi Jeroen,
>
> I just gave your quickstart a spin.
>
> After some debugging I see that this is what happens: because you set the
> redirect mode to ALWAYS_REDIRECT, wicket needs to generate a target url to
> redirect to.
> It determines if the page is stateless (in your case: yes), can be created
> from a bookmarkable url (in your case: yes) and then generates a stateless
> url (“/error”).
>
> This makes sense: you basically tell wicket that this is a stateless page
> that can be recreated easily.
>
> So here are two possible ways for you to remedy this:
>
> A) remove the stateless/bookmarkable constructor (the zero-args one)
> B) explicitly mark the page as stateful (call "setStatelessHint( false );”
> after “init(e);” in your stateful constructor
>
> Since the error page requires an exception to be able to be of use - what
> is the point of having the zero-args constructor?
> So that would be the logical fix for me: remove the zero-arg constructor.
>
> Hope this helps!
>
> Met vriendelijke groet,
> Kind regards,
>
> Bas Gooren
>
> Op 11 november 2021 bij 13:59:27, Jeroen Steenbeeke (
> j.steenbeeke.ml@gmail.com) schreef:
>
> Our application uses an implementation of IRequestCycleListener to
> redirect
> users to a custom error page with contextual information (which includes a
> reference to an external bug tracking system).
>
> When the target page is also mounted in the application, we are seeing
> rather unexpected behavior: the custom error page is created as expected,
> but Wicket then tries to recreate the page by calling a default
> constructor
> (which exists), rendering the error page without the contextual
> information.
>
> Is this expected behavior, or is this a bug?
>
> I've created the following quickstart to illustrate the problem:
>
>
> https://github.com/jsteenbeeke/wicket-custom-mounted-errorpage-loses-context
>
> Sincerely,
>
> Jeroen Steenbeeke
>
>

-- 
Jeroen Steenbeeke

Re: Custom error handler (IRequestCycleListener) with Bookmarkable page

Posted by Bas Gooren <ba...@iswd.nl>.
Hi Jeroen,

I just gave your quickstart a spin.

After some debugging I see that this is what happens: because you set the
redirect mode to ALWAYS_REDIRECT, wicket needs to generate a target url to
redirect to.
It determines if the page is stateless (in your case: yes), can be created
from a bookmarkable url (in your case: yes) and then generates a stateless
url (“/error”).

This makes sense: you basically tell wicket that this is a stateless page
that can be recreated easily.

So here are two possible ways for you to remedy this:

A) remove the stateless/bookmarkable constructor (the zero-args one)
B) explicitly mark the page as stateful (call "setStatelessHint( false );”
after “init(e);” in your stateful constructor

Since the error page requires an exception to be able to be of use - what
is the point of having the zero-args constructor?
So that would be the logical fix for me: remove the zero-arg constructor.

Hope this helps!

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 11 november 2021 bij 13:59:27, Jeroen Steenbeeke (
j.steenbeeke.ml@gmail.com) schreef:

Our application uses an implementation of IRequestCycleListener to redirect
users to a custom error page with contextual information (which includes a
reference to an external bug tracking system).

When the target page is also mounted in the application, we are seeing
rather unexpected behavior: the custom error page is created as expected,
but Wicket then tries to recreate the page by calling a default constructor
(which exists), rendering the error page without the contextual
information.

Is this expected behavior, or is this a bug?

I've created the following quickstart to illustrate the problem:

https://github.com/jsteenbeeke/wicket-custom-mounted-errorpage-loses-context

Sincerely,

Jeroen Steenbeeke