You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

RequestCycle class has been reworked for Wicket 1.5.

General

Now it is better suited for composition by using org.apache.wicket.request.cycle.IRequestCycleListener so it can be extended by several independent libraries. In Wicket 1.4 the user application had to extend (Web)RequestCycle to use the hooks and this made it hard for third party libraries because they don't know about the other and both can extend only WebRequestCycle. Now libraries should register their own IRequestCycleListener (or better AbstractRequestCycleListener) through org.apache.wicket.Application.getRequestCycleListeners().add(listener).

Configuring custom RequestCycle

Extending of the new RequestCycle is still possible. To register custom RequestCycle you have to use org.apache.wicket.Application.setRequestCycleProvider(IRequestCycleProvider).

Tracking requested and response pages

The new RequestCycle implementation doesn't provide methods for getting the page for the current request but this information can be easily tracked with a IRequestCycleListener. Wicket itself uses org.apache.wicket.protocol.http.RequestLoggerRequestCycleListener to track the requested page and the response page for a request. You may use it as inspiration if it doesn't fit your needs as it is.

Exception handling

Whenever an exception occurs org.apache.wicket.request.cycle.IRequestCycleListener.onException(RequestCycle, Exception) will be called for all registered IRequestCycleListeners. The first one that knows how to handle this kind of exception can return IRequestHandler implementation that will be used to proceed the processing of the request. If none of the IRequestCycleListeners can handle it (i.e. all of them return null) then Wicket will use the configured org.apache.wicket.request.IExceptionMapper. The default one will show the configured error pages (internal error, page expired, access denied, etc.).

  • No labels