Example usage for org.apache.wicket.core.request.handler RenderPageRequestHandler getPage

List of usage examples for org.apache.wicket.core.request.handler RenderPageRequestHandler getPage

Introduction

In this page you can find the example usage for org.apache.wicket.core.request.handler RenderPageRequestHandler getPage.

Prototype

@Override
    public IRequestablePage getPage() 

Source Link

Usage

From source file:org.apache.isis.viewer.wicket.viewer.integration.wicket.WebRequestCycleForIsis.java

License:Apache License

/**
 * Is called prior to {@link #onEndRequest(RequestCycle)}, and offers the opportunity to
 * throw an exception.// w  ww . ja v  a 2s . c o m
 */
@Override
public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("onRequestHandlerExecuted: handler: " + handler);
    }

    final IsisSession session = getIsisContext().getSessionInstance();
    if (session != null) {
        try {
            // will commit (or abort) the transaction;
            // an abort will cause the exception to be thrown.
            getTransactionManager().endTransaction();
        } catch (Exception ex) {
            // will redirect to error page after this, 
            // so make sure there is a new transaction ready to go.
            if (getTransactionManager().getTransaction().getState().isComplete()) {
                getTransactionManager().startTransaction();
            }
            if (handler instanceof RenderPageRequestHandler) {
                RenderPageRequestHandler requestHandler = (RenderPageRequestHandler) handler;
                if (requestHandler.getPage() instanceof ErrorPage) {
                    // do nothing
                    return;
                }
            }

            // shouldn't return null given that we're in a session ...
            PageProvider errorPageProvider = errorPageProviderFor(ex);
            throw new RestartResponseException(errorPageProvider, RedirectPolicy.ALWAYS_REDIRECT);
        }
    }
}