You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jarnis <ja...@exedio.com> on 2012/04/04 16:07:52 UTC

Fallback for error page

Hi all

I set up an error page by calling
getApplicationSettings().setInternalErrorPage(ErrorPage.class);
in my application setup. However, I would like to redirect to a static html
page (not a wicket page) if an error occurs, preventing the wicket error
page from being shown.

I thought about wrapping all code in the error page in a try/catch block and
throwing a custom RuntimeException if any exception is thrown on the error
page. I could then setup a custom page with redirection as the error page
for this specific exception. An even simpler solution would be to just
redirect to the static page in the catch block.

The main problem with this approach is that I can't wrap the call to the
parent class' constructor in the try block. Any exception being thrown in
the parent constructor would therefore still result in a loop of error page
redirecting to itself, same as with no fallback.

Is there a good solution to this problem?

Thanks in advance,
Jarnis Bertelsen

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fallback-for-error-page-tp4531970p4531970.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Fallback for error page

Posted by jarnis <ja...@exedio.com>.
Thanks for a quick reply and a useful solution. Being fairly new to wicker it
would never have occurred to me to hook into the request cycle, but I just
finished implementing it (as proof of concept at least) and it works fine.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fallback-for-error-page-tp4531970p4532377.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Fallback for error page

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You can use org.apache.wicket.request.cycle.IRequestCycleListener#onException()
to track how many errors happened in the current request cycle. If
this is the first error then set a flag (e.g. RequestCycle metadata)
and let it be processed with InternalErrorPage (i.e. return null).
Next time when #onException() is called (due to a problem in
InternalErrorPage) you will see the flag and will return: new
RedirectRequestHandler("normal/page.html")
I.e. only the flag will indicate what to do. Don't use your own
exception nor try/catch.

On Wed, Apr 4, 2012 at 4:07 PM, jarnis <ja...@exedio.com> wrote:
> Hi all
>
> I set up an error page by calling
> getApplicationSettings().setInternalErrorPage(ErrorPage.class);
> in my application setup. However, I would like to redirect to a static html
> page (not a wicket page) if an error occurs, preventing the wicket error
> page from being shown.
>
> I thought about wrapping all code in the error page in a try/catch block and
> throwing a custom RuntimeException if any exception is thrown on the error
> page. I could then setup a custom page with redirection as the error page
> for this specific exception. An even simpler solution would be to just
> redirect to the static page in the catch block.
>
> The main problem with this approach is that I can't wrap the call to the
> parent class' constructor in the try block. Any exception being thrown in
> the parent constructor would therefore still result in a loop of error page
> redirecting to itself, same as with no fallback.
>
> Is there a good solution to this problem?
>
> Thanks in advance,
> Jarnis Bertelsen
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fallback-for-error-page-tp4531970p4531970.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org