wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: Fallback for error page
Date Wed, 04 Apr 2012 14:42:18 GMT
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 <jarnis.bertelsen@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


Mime
View raw message