org.wamblee.wicket.transactions
Class OpenTransactionInViewRequestCycle

java.lang.Object
  extended by org.apache.wicket.RequestCycle
      extended by org.apache.wicket.protocol.http.WebRequestCycle
          extended by org.wamblee.wicket.transactions.OpenTransactionInViewRequestCycle

public class OpenTransactionInViewRequestCycle
extends org.apache.wicket.protocol.http.WebRequestCycle

This class provides an Open Transaction in View implementation for wicket. It provides a custom request cycle that uses the UserTransaction to make sure that all work is done within a single transaction. In Hibernate context, this is referred to as open session in view.

The method used by this class is more correctly called Open Transaction in View and has a similar effect to open session in view. It is however more general because it supports any (JTA) transactional resource. Also it is more efficient/scalable than most open session in view implementations because a database connection is only obtained from the connection pool when it is needed.

To use this request cycle, add it in your wicket Application subclass by overriding Application.newRequestCycle(org.apache.wicket.Request, Response). For example:

 @Override
 public RequestCycle newRequestCycle(Request aRequest, Response aResponse) {
     return new OpenTransactionInViewRequestCycle(this, (WebRequest) aRequest,
         aResponse);
 }
 

Author:
Erik Brakkee

Field Summary
 
Fields inherited from class org.apache.wicket.RequestCycle
application, processor, request, response
 
Constructor Summary
OpenTransactionInViewRequestCycle(org.apache.wicket.protocol.http.WebApplication aApplication, org.apache.wicket.protocol.http.WebRequest aRequest, org.apache.wicket.Response aResponse)
          Constructs the request cycle.
 
Method Summary
protected  void onBeginRequest()
           
protected  void onEndRequest()
           
 org.apache.wicket.Page onRuntimeException(org.apache.wicket.Page aPage, java.lang.RuntimeException aE)
           
 
Methods inherited from class org.apache.wicket.protocol.http.WebRequestCycle
getProcessor, getWebRequest, getWebResponse, getWebSession, isRedirect, newBrowserInfoPage, newClientInfo, redirectTo
 
Methods inherited from class org.apache.wicket.RequestCycle
detach, get, getApplication, getClientInfo, getMetaData, getOriginalResponse, getPageParameters, getRedirect, getRequest, getRequestTarget, getResponse, getResponsePage, getResponsePageClass, getSession, getStartTime, isUrlForNewWindowEncoding, logRuntimeException, onAfterTargetsDetached, onRequestTargetSet, request, request, request, set, setAutomaticallyClearFeedbackMessages, setMetaData, setRedirect, setRequest, setRequestTarget, setResponse, setResponsePage, setResponsePage, setResponsePage, setResponsePage, setUrlForNewWindowEncoding, toString, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, wasHandled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OpenTransactionInViewRequestCycle

public OpenTransactionInViewRequestCycle(org.apache.wicket.protocol.http.WebApplication aApplication,
                                         org.apache.wicket.protocol.http.WebRequest aRequest,
                                         org.apache.wicket.Response aResponse)
Constructs the request cycle.

Parameters:
aApplication - Application to use.
aRequest - Request
aResponse - Response.
Method Detail

onBeginRequest

protected void onBeginRequest()
Overrides:
onBeginRequest in class org.apache.wicket.RequestCycle

onEndRequest

protected void onEndRequest()
Overrides:
onEndRequest in class org.apache.wicket.RequestCycle

onRuntimeException

public org.apache.wicket.Page onRuntimeException(org.apache.wicket.Page aPage,
                                                 java.lang.RuntimeException aE)
Overrides:
onRuntimeException in class org.apache.wicket.RequestCycle


Copyright © 2022. All Rights Reserved.