atg.epub.servlet
Class PortletFormHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.epub.servlet.PortletFormHandler
All Implemented Interfaces:
atg.droplet.ObjectFormHandler, atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
atg.epub.servlet.BaseSearchFormHandler, PublishingPortletFormHandler

public abstract class PortletFormHandler
extends GenericService
implements atg.droplet.ObjectFormHandler

Base form handler class for creating Portlet form handlers within the Portals framework. This class adds automatic transaction creation and formException support.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  java.util.List mFormExceptions
           
 java.lang.String PARAM_USE_FORWARDS
          The name of a parameter that represents whether to use forwards.
protected static javax.transaction.TransactionManager sTransactionManager
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
PortletFormHandler()
           
 
Method Summary
 void addFormException(java.lang.Throwable pFormException)
          Set the formExceptions property.
 void afterGet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 void afterGet(java.lang.Object pRequest, java.lang.Object pResponse)
           
 void afterGet(javax.portlet.PortletRequest pRequest, javax.portlet.PortletResponse pResponse)
           
 boolean afterSet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 boolean afterSet(java.lang.Object pRequest, java.lang.Object pResponse)
           
 boolean afterSet(javax.portlet.PortletRequest pRequest, javax.portlet.PortletResponse pResponse)
           
 void beforeGet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 void beforeGet(java.lang.Object pRequest, java.lang.Object pResponse)
           
 void beforeGet(javax.portlet.PortletRequest pRequest, javax.portlet.PortletResponse pResponse)
           
 boolean beforeSet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 boolean beforeSet(java.lang.Object pRequest, java.lang.Object pResponse)
           
 boolean beforeSet(javax.portlet.PortletRequest pRequest, javax.portlet.PortletResponse pResponse)
           
 boolean checkFormRedirect(java.lang.String pSuccessURL, java.lang.String pFailureURL, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          If NO form errors are found, redirect to the SuccessURL.
 boolean getCheckForValidSession()
           
protected  DynamoHttpServletRequest getCurrentDynamoRequest(javax.portlet.PortletRequest pRequest)
           
protected  DynamoHttpServletResponse getCurrentDynamoResponse(DynamoHttpServletRequest pRequest)
           
 boolean getFormError()
          Return true if there are any formExceptions, otherwise return false
 java.util.List getFormExceptions()
          Return the formExceptions property.
 java.util.Dictionary getPropertyExceptions()
          Returns the propertyExceptions property.
protected  TransactionDemarcation getTransactionDemarcation()
          Returns property TransactionDemarcation.
 void handleFormException(DropletFormException pException, java.lang.Object pRequest, java.lang.Object pResponse)
           
 void handleUncheckedFormException(java.lang.Throwable exception, java.lang.Object request, java.lang.Object response)
           
 boolean hasFormExceptions()
          Return true if there are any formExceptions, otherwise return false
 boolean isEnsureTransaction()
          Returns property EnsureTransaction, if false then no transaction management is performed
 boolean isRestorableForm()
           
protected  boolean isRollbackTransaction()
          Returns property RollbackTransaction.
 boolean isUseForwards()
          Get whether to use forwards rather then redirects
 boolean isValidSession(DynamoHttpServletRequest pRequest)
          Returns true if this is a valid session for processing the form.
protected  void redirectOrForward(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, java.lang.String pURL)
          Forward or redirect, as required.
 void resetFormExceptions()
          Clears out all form exceptions
 void setCheckForValidSession(boolean pCheckForValidSession)
          Sets the property CheckForValidSession.
 void setEnsureTransaction(boolean pEnsureTransaction)
          Sets property EnsureTransaction
 void setRestorableForm(boolean pRestorableForm)
          Sets the property RestorableForm.
protected  void setRollbackTransaction(boolean pRollbackTransaction)
          Sets property RollbackTransaction
protected  void setTransactionDemarcation(TransactionDemarcation pTransactionDemarcation)
          Sets property TransactionDemarcation Since this component can be session scoped, multiple requests using the same session scoped form handler can collide with their use of the form handler.
 void setUseForwards(boolean pUseForwards)
          Set whether to use forwards rather then redirects.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


PARAM_USE_FORWARDS

public final java.lang.String PARAM_USE_FORWARDS
The name of a parameter that represents whether to use forwards. The form handler defaults to using redirects. Set this to "true" to use forwards instead.

See Also:
Constant Field Values

sTransactionManager

protected static javax.transaction.TransactionManager sTransactionManager

mFormExceptions

protected java.util.List mFormExceptions
Constructor Detail

PortletFormHandler

public PortletFormHandler()
Method Detail

setEnsureTransaction

public void setEnsureTransaction(boolean pEnsureTransaction)
Sets property EnsureTransaction


isEnsureTransaction

public boolean isEnsureTransaction()
Returns property EnsureTransaction, if false then no transaction management is performed


setTransactionDemarcation

protected void setTransactionDemarcation(TransactionDemarcation pTransactionDemarcation)
Sets property TransactionDemarcation Since this component can be session scoped, multiple requests using the same session scoped form handler can collide with their use of the form handler. This method stores the attribute in the current request.


getTransactionDemarcation

protected TransactionDemarcation getTransactionDemarcation()
Returns property TransactionDemarcation. This object that is used to manage transactions in the beforeSet and afterSet methods. This is created in the beforeSet method and set to null in afterSet.


setRollbackTransaction

protected void setRollbackTransaction(boolean pRollbackTransaction)
Sets property RollbackTransaction


isRollbackTransaction

protected boolean isRollbackTransaction()
Returns property RollbackTransaction. If this is true, then the transaction will be marked for rollback in the afterSet method. This defaults to false and is reset to false in afterSet.


setCheckForValidSession

public void setCheckForValidSession(boolean pCheckForValidSession)
Sets the property CheckForValidSession. If your form handler depends on session information to be maintained between when the form was rendered and when the form is submitted, you can set this property to true to have this form handler automatically detect when a form submit occurs on a new session. This error checking only works if you use the checkFormRedirect method in your handleX method.

If you set this property to true and use the checkFormRedirect method, it will add a form exception with the code "sessionExpired" and redirect to the supplied errorURL if the session expired between when the form was rendered and submitted.

Note that if the session backup feature is enabled, you should be sure to set the RestorableForm property to true if your form can work properly on a restored session.

Parameters:
pCheckForValidSession - new value to set

getCheckForValidSession

public boolean getCheckForValidSession()
Returns:
The value of the property CheckForValidSession.

isValidSession

public boolean isValidSession(DynamoHttpServletRequest pRequest)
Returns true if this is a valid session for processing the form. This is meant to be called during the form processing stage of the request handling pipeline (i.e. from a set or handle method in the form).


setRestorableForm

public void setRestorableForm(boolean pRestorableForm)
Sets the property RestorableForm. Set this property to true if this form handler can properly process form results on a session which has been restored using the session backup server. This property is only used by the isValidSession method. That method gets used to automatically detect an error and redirect to the error page when your session has expired since the form was rendered.

You should set this property to true, if you are using the checkFormRedirect method in your handleX method, and all of the data needed to process this form in your session is restored by the session backup process.

Note that if your form does not rely on any data in the session at all for processing, you do not need to worry about setting this property. Instead, make sure to set the checkForValidSession property to false.

Parameters:
pRestorableForm - new value to set

isRestorableForm

public boolean isRestorableForm()
Returns:
The value of the property RestorableForm.

setUseForwards

public void setUseForwards(boolean pUseForwards)
Set whether to use forwards rather then redirects.


isUseForwards

public boolean isUseForwards()
Get whether to use forwards rather then redirects


hasFormExceptions

public boolean hasFormExceptions()
Return true if there are any formExceptions, otherwise return false


getFormError

public boolean getFormError()
Return true if there are any formExceptions, otherwise return false


getFormExceptions

public java.util.List getFormExceptions()
Return the formExceptions property. Returns null if there are no form exceptions, otherwise returns a List of Exception objects.


addFormException

public void addFormException(java.lang.Throwable pFormException)
Set the formExceptions property.

Parameters:
pErrorURL -

resetFormExceptions

public void resetFormExceptions()
Clears out all form exceptions


getPropertyExceptions

public java.util.Dictionary getPropertyExceptions()
Returns the propertyExceptions property. This is a Dictionary that returns the current form exceptions keyed off of the name of the property that generated that exception. A DynamicPropertyMapper is registered for these exceptions so that you can access them as properties in a jhtml page. If there was no exception for a particular property, a null value is returned for that property.


getCurrentDynamoRequest

protected DynamoHttpServletRequest getCurrentDynamoRequest(javax.portlet.PortletRequest pRequest)

getCurrentDynamoResponse

protected DynamoHttpServletResponse getCurrentDynamoResponse(DynamoHttpServletRequest pRequest)

beforeSet

public boolean beforeSet(java.lang.Object pRequest,
                         java.lang.Object pResponse)
                  throws DropletFormException
Specified by:
beforeSet in interface atg.droplet.ObjectFormHandler
Throws:
DropletFormException

beforeSet

public boolean beforeSet(javax.portlet.PortletRequest pRequest,
                         javax.portlet.PortletResponse pResponse)
                  throws DropletFormException
Throws:
DropletFormException

beforeSet

public boolean beforeSet(DynamoHttpServletRequest pRequest,
                         DynamoHttpServletResponse pResponse)
                  throws DropletFormException
Throws:
DropletFormException

afterSet

public boolean afterSet(java.lang.Object pRequest,
                        java.lang.Object pResponse)
                 throws DropletFormException
Specified by:
afterSet in interface atg.droplet.ObjectFormHandler
Throws:
DropletFormException

afterSet

public boolean afterSet(javax.portlet.PortletRequest pRequest,
                        javax.portlet.PortletResponse pResponse)
                 throws DropletFormException
Throws:
DropletFormException

afterSet

public boolean afterSet(DynamoHttpServletRequest pRequest,
                        DynamoHttpServletResponse pResponse)
                 throws DropletFormException
Throws:
DropletFormException

beforeGet

public void beforeGet(java.lang.Object pRequest,
                      java.lang.Object pResponse)
Specified by:
beforeGet in interface atg.droplet.ObjectFormHandler

beforeGet

public void beforeGet(javax.portlet.PortletRequest pRequest,
                      javax.portlet.PortletResponse pResponse)

beforeGet

public void beforeGet(DynamoHttpServletRequest pRequest,
                      DynamoHttpServletResponse pResponse)

afterGet

public void afterGet(java.lang.Object pRequest,
                     java.lang.Object pResponse)
Specified by:
afterGet in interface atg.droplet.ObjectFormHandler

afterGet

public void afterGet(javax.portlet.PortletRequest pRequest,
                     javax.portlet.PortletResponse pResponse)

afterGet

public void afterGet(DynamoHttpServletRequest pRequest,
                     DynamoHttpServletResponse pResponse)

handleFormException

public void handleFormException(DropletFormException pException,
                                java.lang.Object pRequest,
                                java.lang.Object pResponse)
Specified by:
handleFormException in interface atg.droplet.ObjectFormHandler

handleUncheckedFormException

public void handleUncheckedFormException(java.lang.Throwable exception,
                                         java.lang.Object request,
                                         java.lang.Object response)
Specified by:
handleUncheckedFormException in interface atg.droplet.ObjectFormHandler

checkFormRedirect

public boolean checkFormRedirect(java.lang.String pSuccessURL,
                                 java.lang.String pFailureURL,
                                 DynamoHttpServletRequest pRequest,
                                 DynamoHttpServletResponse pResponse)
                          throws javax.servlet.ServletException,
                                 java.io.IOException
If NO form errors are found, redirect to the SuccessURL. If form errors are found, redirect to the FailureURL.

Parameters:
pNoErrorsURL - The URL to redirect to if there were no form errors. If a null value is passed in, no redirect occurs.
pErrorsURL - The URL to redirect to if form errors were found. If a null value is passed in, no redirect occurs.
pRequest - the servlet's request
pResponse - the servlet's response
Returns:
If redirect (for whatever reason) to a new page occurred, return false. If NO redirect occurred, return true.
Throws:
javax.servlet.ServletException - if there was an error while executing the code
java.io.IOException - if there was an error with servlet io

redirectOrForward

protected void redirectOrForward(DynamoHttpServletRequest pRequest,
                                 DynamoHttpServletResponse pResponse,
                                 java.lang.String pURL)
                          throws java.io.IOException,
                                 javax.servlet.ServletException
Forward or redirect, as required.

Parameters:
pRequest - the servlet's request
pResponse - the servlet's response
pURL - the url to redirect or forward to.
Throws:
java.io.IOException
javax.servlet.ServletException