org.apache.beehive.netui.pageflow
Class FlowController

Object
  extended by PageFlowManagedObject
      extended by FlowController
All Implemented Interfaces:
Serializable, EventListener, HttpSessionBindingListener, ActionResolver, PageFlowConstants
Direct Known Subclasses:
PageFlowController, SharedFlowController

public abstract class FlowController
extends PageFlowManagedObject
implements PageFlowConstants, ActionResolver

Base class for user-written flow controllers - PageFlowControllers and Global.app.

See Also:
Serialized Form

Field Summary
protected static Locale defaultLocale
          Deprecated. Use getDefaultLocale().
protected  ActionServlet servlet
          Deprecated. This variable will be removed with no replacement. In most cases, PageFlowManagedObject.getServletContext() is sufficient; for other cases, the ActionServlet itself is in the ServletContext attribute Globals.ACTION_SERVLET_KEY.
 
Fields inherited from interface PageFlowConstants
ACTION_EXTENSION, ACTION_OVERRIDE, BEGIN_ACTION_NAME, DEFAULT_FORWARD_OVERFLOW_COUNT, DEFAULT_NESTING_OVERFLOW_COUNT, FORWARD_OVERFLOW_COUNT_PARAM, GLOBALAPP_CLASSNAME, GLOBALAPP_SOURCEFILE_NAME, HTTP_REDIRECTOR_PARAM, JPF_EXTENSION, JPF_MODULE_CONFIG_EXTENSION, JPF_MODULE_CONFIG_GEN_DIR, JPF_MODULE_CONFIG_PREFIX, LOGIN_HANDLER_PARAM, NESTING_OVERFLOW_COUNT_PARAM, SECURE_FORWARDS_PARAM
 
Constructor Summary
protected FlowController()
          Default constructor.
 
Method Summary
protected  void addValidationError(String propertyName, String messageKey)
          Add a validation error that will be shown with the Errors and Error tags.
protected  void addValidationError(String propertyName, String messageKey, Object[] messageArgs)
          Add a validation error that will be shown with the Errors and Error tags.
protected  void afterAction()
          Callback that occurs after any user action method is invoked.
protected  boolean alwaysTrackPreviousAction()
          When the current page flow does not use a @jpf:forward with a return-to="previousAction" attribute, the following methods always return null by default.
protected  boolean alwaysTrackPreviousPage()
          When the current page flow does not use a @jpf:forward with either a return-to="currentPage" or a return-to="previousPage" attribute, the following methods always return null by default.
protected  void beforeAction()
          Callback that occurs before any user action method is invoked.
protected  void delete()
           
 ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
          Perform decision logic to determine the next URI to be displayed.
protected  String generateToken(HttpServletRequest request)
          Deprecated. Use
protected  ActionMapping getActionMapping()
          Get the current Struts ActionMapping, which is information from the Struts-XML <action> tag that corresponds to the current page flow action being executed.
protected  Method getActionMethod(String methodName, Class argType)
          Get an action handler method of the given name/signature .
 String[] getActions()
          Get a list of the names of actions handled by methods in this PageFlowController.
protected  String getCurrentActionName()
          Get the name of the current action being executed.
protected  DataSource getDataSource(HttpServletRequest request)
          Return the default data source for the module associated with this page flow.
protected  DataSource getDataSource(HttpServletRequest request, String key)
          Return the specified data source for the current module.
protected static Locale getDefaultLocale()
          Get the system default locale.
protected  Locale getLocale()
          Return the user's currently selected Locale.
protected  Locale getLocale(HttpServletRequest request)
          Deprecated. Use getLocale().
protected  ActionMapping getMapping()
          Deprecated. Use getActionMapping() instead.
 ModuleConfig getModuleConfig()
           
 ModuleConfig getModuleConfig(ServletContext servletContext, HttpServletRequest request)
          Gets the Struts module configuration associated with this controller.
abstract  String getModulePath()
          Get the Struts module path for this controller.
protected  HttpServletRequest getRequest()
          Get the current HttpServletRequest.
protected  MessageResources getResources()
          Deprecated. This method can only return the resources for the default module. Use getResources(HttpServletRequest) to get the resources for the current module.
protected  MessageResources getResources(HttpServletRequest request)
          Return the default message resources for the current module.
protected  MessageResources getResources(HttpServletRequest request, String key)
          Return the specified message resources for the current module.
protected  HttpServletResponse getResponse()
          Get the current HttpServletResponse.
protected  ActionServlet getServlet()
          Deprecated. This method will be removed with no replacement. In most cases, PageFlowManagedObject.getServletContext() is sufficient; for other cases, the ActionServlet itself is in the ServletContext attribute Globals.ACTION_SERVLET_KEY.
protected  HttpSession getSession()
          Get the current user session.
protected  ActionForward handleException(Throwable ex, ActionMapping mapping, String actionName, ActionForm form, HttpServletRequest request, HttpServletResponse response)
          Handle the given exception - invoke user code if appropriate and return a destination URI.
protected  ActionForward internalExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
           
protected  ActionForward invokeActionMethod(Method method, Object arg)
          Invoke the given action handler method, passing it an argument if appropriate.
 ActionForward invokeExceptionHandler(Method method, Throwable ex, String actionName, String message, Object formBean, ActionForm wrappedFormBean, ActionMapping actionMapping, HttpServletRequest request, HttpServletResponse response, boolean readonly)
          Invoke the given exception handler method.
 boolean isAction(String name)
          Tell whether a given String is the name of an action handled by a method in this PageFlowController.
protected  boolean isCancelled(HttpServletRequest request)
          Returns true if the current form's cancel button was pressed.
protected  boolean isNestable()
          Tell whether this PageFlowController can be "nested", i.e., if it can be invoked from another page flow with the intention of returning to the original one.
 boolean isPageFlow()
          Tell whether this is a PageFlowController.
protected  boolean isSingleton()
          Tell whether this is a "singleton" page flow.
protected  boolean isTokenValid(HttpServletRequest request)
          Return true if there is a transaction token stored in the user's current session, and the value submitted as a request parameter with this action matches it.
protected  boolean isTokenValid(HttpServletRequest request, boolean reset)
          Return true if there is a transaction token stored in the user's current session, and the value submitted as a request parameter with this action matches it.
 void login(String username, String password)
          Log in the user, using "weak" username/password authentication.
 void logout(boolean invalidateSessions)
          Log out the current user.
static ActionResult lookup(String actionName, ServletContext context, HttpServletRequest request, HttpServletResponse response)
          Deprecated. Use PageFlowUtils.strutsLookup(javax.servlet.ServletContext, javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.String[]) instead.
static ActionResult lookup(String actionName, ServletContext context, HttpServletRequest request, HttpServletResponse response, String actionServletClassName)
          Deprecated. Use PageFlowUtils.strutsLookup(javax.servlet.ServletContext, javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.String[]) instead.
protected  void onCreate()
          Callback that is invoked when this controller instance is created.
protected  void onDestroy()
          Deprecated. onDestroy(javax.servlet.http.HttpSession) should be used instead.
protected  void onDestroy(HttpSession session)
          Callback that is invoked when this controller instance is "destroyed", i.e., removed from the user session.
protected  void onRefresh()
          Callback that is invoked when this controller is involved in a refresh request, as can happen in a portal environment on a request where no action is run in the current page flow, but a previously-displayed JSP in the page flow is re-rendered.
 void refresh(HttpServletRequest request, HttpServletResponse response)
          Called on this object for non-lookup (refresh) requests.
 void reinitialize(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Initialize transient data that may have been lost during session failover.
protected  void resetToken(HttpServletRequest request)
          Reset the saved transaction token in the user's session.
 String resolveAction(String actionName, Object form)
          Deprecated. Use resolveAction(String, Object, HttpServletRequest, HttpServletResponse) instead.
 String resolveAction(String actionName, Object form, HttpServletRequest request, HttpServletResponse response)
          Call an action and return the result URI.
static Locale retrieveUserLocale(HttpServletRequest request, String locale)
           
protected  void saveErrors(HttpServletRequest request, ActionErrors errors)
          Save the specified error messages keys into the appropriate request attribute for use by the <html:errors> tag, if any messages are required.
protected  void saveMessages(HttpServletRequest request, ActionMessages messages)
          Save the specified messages keys into the appropriate request attribute for use by the <html:messages> tag (if messages="true" is set), if any messages are required.
protected  void saveToken(HttpServletRequest request)
          Save a new transaction token in the user's current session, creating a new session if necessary.
protected  void sendError(String errText, HttpServletRequest request, HttpServletResponse response)
          Send a Page Flow error to the browser.
protected  void sendError(String errText, HttpServletResponse response)
          Deprecated. Use sendError(String, HttpServletRequest, HttpServletResponse) instead.
protected  void setLocale(HttpServletRequest request, Locale locale)
          Deprecated. Use setLocale(java.util.Locale).
protected  void setLocale(Locale locale)
           
 
Methods inherited from class PageFlowManagedObject
deleteFromSession, ensureFailover, fieldIsUninitialized, getDisplayName, getServletContext, initializeField, valueBound, valueUnbound
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ActionResolver
getURI
 

Field Detail

defaultLocale

protected static Locale defaultLocale
Deprecated. Use getDefaultLocale().
The system default Locale.


servlet

protected transient ActionServlet servlet
Deprecated. This variable will be removed with no replacement. In most cases, PageFlowManagedObject.getServletContext() is sufficient; for other cases, the ActionServlet itself is in the ServletContext attribute Globals.ACTION_SERVLET_KEY.
Get the current Struts ActionServlet.

Constructor Detail

FlowController

protected FlowController()
Default constructor.

Method Detail

reinitialize

public void reinitialize(HttpServletRequest request,
                         HttpServletResponse response,
                         ServletContext servletContext)
Description copied from class: PageFlowManagedObject
Initialize transient data that may have been lost during session failover.

Overrides:
reinitialize in class PageFlowManagedObject

login

public void login(String username,
                  String password)
           throws LoginException
Log in the user, using "weak" username/password authentication.

Parameters:
username - the user's login name
password - the user's password
Throws:
LoginException - if the authentication failed

logout

public void logout(boolean invalidateSessions)
Log out the current user. This causes the user to be removed from Servlet Session (on all single-signon webapps) as well as from the thread.

Parameters:
invalidateSessions - if true, the session is invalidated (on all single-signon webapps); otherwise the session and its data are left intact (except for authentication information used internally by the server). To invalidate the session in only the current webapp, set this parameter to false and call getSession().invalidate().

sendError

protected void sendError(String errText,
                         HttpServletResponse response)
                  throws IOException
Deprecated. Use sendError(String, HttpServletRequest, HttpServletResponse) instead.

Send a Page Flow error to the browser.

Parameters:
errText - the error message to display.
response - the current HttpServletResponse.
Throws:
IOException

sendError

protected void sendError(String errText,
                         HttpServletRequest request,
                         HttpServletResponse response)
                  throws IOException
Send a Page Flow error to the browser.

Parameters:
errText - the error message to display.
response - the current HttpServletResponse.
Throws:
IOException

handleException

protected ActionForward handleException(Throwable ex,
                                        ActionMapping mapping,
                                        String actionName,
                                        ActionForm form,
                                        HttpServletRequest request,
                                        HttpServletResponse response)
                                 throws Exception
Handle the given exception - invoke user code if appropriate and return a destination URI.

Parameters:
ex - the Exception to handle.
mapping - the Struts action mapping for current Struts action being processed.
actionName - the name of the Struts action being processed.
form - the form-bean (if any) associated with the Struts action being processed. May be null.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
Returns:
a Struts ActionForward object that specifies the URI that should be displayed.
Throws:
Exception - if another Exception is thrown during handling of ex.

getCurrentActionName

protected String getCurrentActionName()
Get the name of the current action being executed. This call is only valid during execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (where any user action method is invoked), and during the lifecycle methods beforeAction() and afterAction().

Returns:
the name of the current action being executed.
Throws:
IllegalStateException - if this method is invoked outside of action method execution (i.e., outside of the call to execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), and outside of onCreate(), beforeAction(), afterAction().

execute

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
                      throws Exception
Perform decision logic to determine the next URI to be displayed.

Parameters:
mapping - the Struts ActionMapping for the current action being processed.
form - the form-bean (if any) associated with the Struts action being processed. May be null.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
Returns:
a Struts ActionForward object that specifies the next URI to be displayed.
Throws:
Exception - if an Exception was thrown during user action-handling code.

internalExecute

protected ActionForward internalExecute(ActionMapping mapping,
                                        ActionForm form,
                                        HttpServletRequest request,
                                        HttpServletResponse response)
                                 throws Exception
Throws:
Exception

getModulePath

public abstract String getModulePath()
Get the Struts module path for this controller.

Specified by:
getModulePath in interface ActionResolver
Returns:
a String that is the Struts module path for this controller - the parent directory for a PageFlowController and "/-global" for Global.app.

beforeAction

protected void beforeAction()
                     throws Exception
Callback that occurs before any user action method is invoked. getRequest(), getResponse(), getSession(), and getActionMapping() may all be used during this method. The action to be run can be discovered by calling ActionConfig.getPath() on the value returned from getActionMapping().

Throws:
Exception

afterAction

protected void afterAction()
                    throws Exception
Callback that occurs after any user action method is invoked. getRequest(), getResponse(), getSession(), and getActionMapping() may all be used during this method. The action that was run can be discovered by calling ActionConfig.getPath() on the value returned from getActionMapping().

Throws:
Exception

onCreate

protected void onCreate()
                 throws Exception
Callback that is invoked when this controller instance is created. getRequest(), getResponse(), getSession() may all be used during this method.

Overrides:
onCreate in class PageFlowManagedObject
Throws:
Exception

onDestroy

protected void onDestroy()
Deprecated. onDestroy(javax.servlet.http.HttpSession) should be used instead.

Callback that is invoked when this controller instance is "destroyed", i.e., removed from the user session. getRequest(), getResponse(), and getActionMapping() may not be used during this method, since it may be called due to session termination outside of a request. getSession() also may not be used, but the session is passed as an argument to onDestroy(javax.servlet.http.HttpSession), which should be used in place of this method.
Note that this method is not synchronized. It is dangerous to synchronize your override of this method because it is invoked during a callback from the Servlet container. Depending on the container, synchronization here can cause deadlocks.


onDestroy

protected void onDestroy(HttpSession session)
Callback that is invoked when this controller instance is "destroyed", i.e., removed from the user session. getRequest(), getResponse(), and getActionMapping() may not be used during this method, since it may be called due to session termination outside of a request. getSession() also may not be used, but the session is passed as an argument.
Note that this method is not synchronized. It is dangerous to synchronize your override of this method because it is invoked during a callback from the Servlet container. Depending on the container, synchronization here can cause deadlocks.

Overrides:
onDestroy in class PageFlowManagedObject

getActionMethod

protected Method getActionMethod(String methodName,
                                 Class argType)
Get an action handler method of the given name/signature .

Parameters:
methodName - the name of the action handler method to query.
argType - the type of the argument to the action handler method; if null, the method takes no arguments.
Returns:
the desired Method, or null if it doesn't exist.

invokeActionMethod

protected ActionForward invokeActionMethod(Method method,
                                           Object arg)
                                    throws Exception
Invoke the given action handler method, passing it an argument if appropriate.

Parameters:
method - the action handler method to invoke.
arg - the form-bean to pass; may be null.
Returns:
the ActionForward returned by the action handler method.
Throws:
Exception - if an Exception was raised in user code.

getRequest

protected final HttpServletRequest getRequest()
Get the current HttpServletRequest. This call is only valid during execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (where any user action method is invoked), and during the lifecycle methods onCreate(), beforeAction(), afterAction().

Returns:
the current HttpServletRequest.
Throws:
IllegalStateException - if this method is invoked outside of action method execution (i.e., outside of the call to execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), and outside of onCreate(), beforeAction(), afterAction().

getResponse

protected final HttpServletResponse getResponse()
Get the current HttpServletResponse. This call is only valid during execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (where any user action method is invoked), and during the lifecycle methods onCreate(), beforeAction(), afterAction().

Returns:
the current HttpServletResponse.
Throws:
IllegalStateException - if this method is invoked outside of action method execution (i.e., outside of the call to execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), and outside of onCreate(), beforeAction(), afterAction().

getMapping

protected final ActionMapping getMapping()
Deprecated. Use getActionMapping() instead.

Get the current Struts ActionMapping, which is information from the Struts-XML <action> tag that corresponds to the current page flow action being executed. This call is only valid during execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (where any user action method is invoked), and during the lifecycle methods beforeAction() and afterAction().

Returns:
the current Struts ActionMapping.
Throws:
IllegalStateException - if this method is invoked outside of action method execution (i.e., outside of the call to execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), and outside of onCreate(), beforeAction(), afterAction().

getActionMapping

protected final ActionMapping getActionMapping()
Get the current Struts ActionMapping, which is information from the Struts-XML <action> tag that corresponds to the current page flow action being executed. This call is only valid during execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (where any user action method is invoked), and during the lifecycle methods beforeAction() and afterAction().

Returns:
the current Struts ActionMapping.
Throws:
IllegalStateException - if this method is invoked outside of action method execution (i.e., outside of the call to execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), and outside of onCreate(), beforeAction(), afterAction().

getSession

protected final HttpSession getSession()
Get the current user session. This call is only valid during execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (where any user action method is invoked), and during the lifecycle methods onCreate(), onDestroy(), beforeAction(), afterAction().

Returns:
the HttpSession for the current user session.
Throws:
IllegalStateException - if this method is invoked outside of action method execution (i.e., outside of the call to execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), and outside of onCreate(), onDestroy(), beforeAction(), afterAction().

getModuleConfig

public final ModuleConfig getModuleConfig()

getModuleConfig

public ModuleConfig getModuleConfig(ServletContext servletContext,
                                    HttpServletRequest request)
Gets the Struts module configuration associated with this controller.

Parameters:
servletContext - the current ServletContext.
Returns:
the Struts ModuleConfig for this controller.

lookup

public static ActionResult lookup(String actionName,
                                  ServletContext context,
                                  HttpServletRequest request,
                                  HttpServletResponse response)
                           throws Exception
Deprecated. Use PageFlowUtils.strutsLookup(javax.servlet.ServletContext, javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.String[]) instead.

Resolve the given action name to a URI. This version assumes that the ActionServlet class should be PageFlowActionServlet. Note: this method invokes the full action-processing cycle on a ScopedRequest. Use resolveAction(java.lang.String, java.lang.Object, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) to resolve the URI for an action in the current page flow.

Throws:
Exception

lookup

public static ActionResult lookup(String actionName,
                                  ServletContext context,
                                  HttpServletRequest request,
                                  HttpServletResponse response,
                                  String actionServletClassName)
                           throws Exception
Deprecated. Use PageFlowUtils.strutsLookup(javax.servlet.ServletContext, javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.String[]) instead.

Resolve the given action name to a URI. Note: this method invokes the full action-processing cycle on a ScopedRequest. Use resolveAction(java.lang.String, java.lang.Object, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) to resolve the URI for an action in the current page flow.

Throws:
Exception

resolveAction

public String resolveAction(String actionName,
                            Object form,
                            HttpServletRequest request,
                            HttpServletResponse response)
                     throws Exception
Call an action and return the result URI.

Parameters:
actionName - the name of the action to run.
form - the form bean instance to pass to the action, or null if none should be passed.
Returns:
the result webapp-relative URI, as a String.
Throws:
ActionNotFoundException - when the given action does not exist in this page flow.
Exception - if the action method throws an Exception.

resolveAction

public String resolveAction(String actionName,
                            Object form)
                     throws Exception
Deprecated. Use resolveAction(String, Object, HttpServletRequest, HttpServletResponse) instead.

Call an action and return the result URI.

Parameters:
actionName - the name of the action to run.
form - the form bean instance to pass to the action, or null if none should be passed.
Returns:
the result webapp-relative URI, as a String.
Throws:
ActionNotFoundException - when the given action does not exist in this page flow.
Exception - if the action method throws an Exception.

getActions

public String[] getActions()
Get a list of the names of actions handled by methods in this PageFlowController.

Returns:
a String array containing the names of actions handled by methods in this PageFlowController.

isAction

public boolean isAction(String name)
Tell whether a given String is the name of an action handled by a method in this PageFlowController.

Parameters:
name - the action-name to query.
Returns:
true if name is the name of an action handled by a method in this PageFlowController.

isPageFlow

public boolean isPageFlow()
Tell whether this is a PageFlowController.

Specified by:
isPageFlow in interface ActionResolver
Returns:
true if this is a PageFlowController.

getServlet

protected ActionServlet getServlet()
Deprecated. This method will be removed with no replacement. In most cases, PageFlowManagedObject.getServletContext() is sufficient; for other cases, the ActionServlet itself is in the ServletContext attribute Globals.ACTION_SERVLET_KEY.

Get the current Struts ActionServlet.

Returns:
the ActionServlet.

refresh

public final void refresh(HttpServletRequest request,
                          HttpServletResponse response)
Called on this object for non-lookup (refresh) requests.

Specified by:
refresh in interface ActionResolver

onRefresh

protected void onRefresh()
Callback that is invoked when this controller is involved in a refresh request, as can happen in a portal environment on a request where no action is run in the current page flow, but a previously-displayed JSP in the page flow is re-rendered.


delete

protected void delete()

isSingleton

protected boolean isSingleton()
Tell whether this is a "singleton" page flow. Once it is invoked, a singleton page flow is never removed from the session unless delete() is called. Navigating to another page flow hides the current singleton controller, but does not remove it.


isNestable

protected boolean isNestable()
Tell whether this PageFlowController can be "nested", i.e., if it can be invoked from another page flow with the intention of returning to the original one. Page flows are declared to be nested using the @jpf:controller nested="true" annotation.

Returns:
true if this PageFlowController can be nested.

alwaysTrackPreviousAction

protected boolean alwaysTrackPreviousAction()
When the current page flow does not use a @jpf:forward with a return-to="previousAction" attribute, the following methods always return null by default. Override alwaysTrackPreviousAction (which always returns false) to enable these methods in all cases.

Returns:
true if the previous action should always be tracked, regardless of whether return-to="previousAction" is used.
See Also:
PageFlowController.getPreviousActionInfo(), PageFlowController.getPreviousActionURI(), PageFlowController.getPreviousForm()

alwaysTrackPreviousPage

protected boolean alwaysTrackPreviousPage()
When the current page flow does not use a @jpf:forward with either a return-to="currentPage" or a return-to="previousPage" attribute, the following methods always return null by default. Override alwaysTrackPreviousPage (which always returns false) to enable these methods in all cases.

Returns:
true if the previous page should always be tracked, regardless of whether return-to="currentPage" or return-to="previousPage" is used.
See Also:
PageFlowController.getCurrentPageInfo(), PageFlowController.getPreviousPageInfo(), PageFlowController.getCurrentForwardPath(), PageFlowController.getPreviousForwardPath()

invokeExceptionHandler

public ActionForward invokeExceptionHandler(Method method,
                                            Throwable ex,
                                            String actionName,
                                            String message,
                                            Object formBean,
                                            ActionForm wrappedFormBean,
                                            ActionMapping actionMapping,
                                            HttpServletRequest request,
                                            HttpServletResponse response,
                                            boolean readonly)
                                     throws Exception
Invoke the given exception handler method.

Parameters:
method - the action handler method to invoke.
ex - the Throwable that is to be handled.
actionName - the name of the Struts action being processed.
message - the String message that is to be passed to the handler method.
formBean - the form bean that is associated with the action being processed; may be null.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
readonly - if true, session failover will not be triggered after invoking the method.
Returns:
the ActionForward returned by the exception handler method.
Throws:
Exception - if an Exception was raised in user code.

addValidationError

protected void addValidationError(String propertyName,
                                  String messageKey,
                                  Object[] messageArgs)
Add a validation error that will be shown with the Errors and Error tags.

Parameters:
propertyName - the name of the property with which to associate this error.
messageKey - the message-resources key for the error message.
messageArgs - an array of arguments for the error message.

addValidationError

protected void addValidationError(String propertyName,
                                  String messageKey)
Add a validation error that will be shown with the Errors and Error tags.

Parameters:
propertyName - the name of the property with which to associate this error.
messageKey - the message-resources key for the error message.

getDefaultLocale

protected static Locale getDefaultLocale()
Get the system default locale.

Returns:
the system default locale.

generateToken

protected String generateToken(HttpServletRequest request)
Deprecated. Use

Generate a new transaction token, to be used for enforcing a single request for a particular transaction.

Parameters:
request - the current request.

getDataSource

protected DataSource getDataSource(HttpServletRequest request)
Return the default data source for the module associated with this page flow.

Parameters:
request - the current request.

getDataSource

protected DataSource getDataSource(HttpServletRequest request,
                                   String key)
Return the specified data source for the current module.

Parameters:
request - The servlet request we are processing
key - The key specified in the <message-resources> element for the requested bundle

getLocale

protected Locale getLocale(HttpServletRequest request)
Deprecated. Use getLocale().

Return the user's currently selected Locale.

Parameters:
request - the current request.
Returns:
the user's currently selected Locale, stored in the session.

getLocale

protected Locale getLocale()
Return the user's currently selected Locale.

Returns:
the user's currently selected Locale, stored in the session.

retrieveUserLocale

public static Locale retrieveUserLocale(HttpServletRequest request,
                                        String locale)

getResources

protected MessageResources getResources()
Deprecated. This method can only return the resources for the default module. Use getResources(HttpServletRequest) to get the resources for the current module.

Return the message resources for the default module.


getResources

protected MessageResources getResources(HttpServletRequest request)
Return the default message resources for the current module.

Parameters:
request - The servlet request we are processing

getResources

protected MessageResources getResources(HttpServletRequest request,
                                        String key)
Return the specified message resources for the current module.

Parameters:
request - the current request.
key - The bundle key specified in a Jpf.MessageResource annotation. <message-resources> element for the requested bundle
Since:
Struts 1.1

isCancelled

protected boolean isCancelled(HttpServletRequest request)

Returns true if the current form's cancel button was pressed. This method will check if the Globals.CANCEL_KEY request attribute has been set, which normally occurs if the cancel button generated by CancelTag was pressed by the user in the current request. If true, validation performed by an ActionForm's validate() method will have been skipped by the controller servlet.

Parameters:
request - The servlet request we are processing
See Also:
CancelTag

isTokenValid

protected boolean isTokenValid(HttpServletRequest request)
Return true if there is a transaction token stored in the user's current session, and the value submitted as a request parameter with this action matches it. Returns false under any of the following circumstances:

Parameters:
request - The servlet request we are processing

isTokenValid

protected boolean isTokenValid(HttpServletRequest request,
                               boolean reset)
Return true if there is a transaction token stored in the user's current session, and the value submitted as a request parameter with this action matches it. Returns false

Parameters:
request - The servlet request we are processing
reset - Should we reset the token after checking it?

resetToken

protected void resetToken(HttpServletRequest request)
Reset the saved transaction token in the user's session. This indicates that transactional token checking will not be needed on the next request that is submitted.

Parameters:
request - The servlet request we are processing

saveErrors

protected void saveErrors(HttpServletRequest request,
                          ActionErrors errors)
Save the specified error messages keys into the appropriate request attribute for use by the <html:errors> tag, if any messages are required. Otherwise, ensure that the request attribute is not created.

Parameters:
request - The servlet request we are processing
errors - Error messages object

saveMessages

protected void saveMessages(HttpServletRequest request,
                            ActionMessages messages)
Save the specified messages keys into the appropriate request attribute for use by the <html:messages> tag (if messages="true" is set), if any messages are required. Otherwise, ensure that the request attribute is not created.

Parameters:
request - The servlet request we are processing
messages - Messages object
Since:
Struts 1.1

saveToken

protected void saveToken(HttpServletRequest request)
Save a new transaction token in the user's current session, creating a new session if necessary.

Parameters:
request - The servlet request we are processing

setLocale

protected void setLocale(HttpServletRequest request,
                         Locale locale)
Deprecated. Use setLocale(java.util.Locale).

Set the user's currently selected Locale.

Parameters:
request - The request we are processing
locale - The user's selected Locale to be set, or null to select the server's default Locale

setLocale

protected void setLocale(Locale locale)