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 SharedFlowControllers.

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, AUTO_VIEW_RENDER_FORWARD_NAME, BEGIN_ACTION_NAME, DEFAULT_FORWARD_OVERFLOW_COUNT, DEFAULT_NESTING_OVERFLOW_COUNT, FORWARD_OVERFLOW_COUNT_PARAM, GLOBALAPP_CLASSNAME, GLOBALAPP_SOURCEFILE_NAME, JPF_EXTENSION, JPF_MODULE_CONFIG_EXTENSION, JPF_MODULE_CONFIG_GEN_DIR, JPF_MODULE_CONFIG_PREFIX, NESTING_OVERFLOW_COUNT_PARAM, PAGEFLOW_EXTENSION, PAGEFLOW_MODULE_CONFIG_EXTENSION, PAGEFLOW_MODULE_CONFIG_GEN_DIR, PAGEFLOW_MODULE_CONFIG_PREFIX, SECURE_FORWARDS_PARAM
 
Constructor Summary
protected FlowController()
          Default constructor.
 
Method Summary
 void addActionError(String propertyName, String messageKey, Object... messageArgs)
          Add a property-related message that will be shown with the Errors and Error tags.
 void addActionErrorExpression(String propertyName, String expression, Object... messageArgs)
          Add a property-related message as an expression that will be evaluated and shown with the Errors and Error tags.
protected  void addValidationError(String propertyName, String messageKey)
          Deprecated. Use addActionError(java.lang.String, java.lang.String, java.lang.Object...) instead.
protected  void addValidationError(String propertyName, String messageKey, Object[] messageArgs)
          Deprecated. Use addActionError(java.lang.String, java.lang.String, java.lang.Object...) instead.
protected  void afterAction()
          Callback that occurs after any user action method is invoked.
protected  boolean alwaysTrackPreviousAction()
          When this FlowController does not use a Jpf.Forward annotation with a navigateTo=Jpf.NavigateTo.previousAction attribute, the following methods always return null by default.
protected  boolean alwaysTrackPreviousPage()
          When this FlowController does not use a Jpf.Forward annotation with either a navigateTo=Jpf.NavigateTo.currentPage attribute or a navigateTo=Jpf.NavigateTo.previousPage attribute, the following methods always return null by default.
protected  void beforeAction()
          Callback that occurs before any user action method is invoked.
 void create(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Initialize.
 ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
          Perform decision logic to determine the next URI to be displayed.
protected  String generateToken()
          Generate a new transaction token, to be used for enforcing a single request for a particular transaction.
protected  String generateToken(HttpServletRequest request)
          Deprecated. Use generateToken() instead.
protected  ActionMapping getActionMapping()
          Get the current Struts ActionMapping, which is information from the Struts-XML <action> tag that corresponds to the current 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.
 MutableURI getActionURI(String actionName)
          Create a raw action URI, which can be modified before being sent through the registered URL rewriting chain using URLRewriterService.rewriteURL(javax.servlet.ServletContext, javax.servlet.ServletRequest, javax.servlet.ServletResponse, org.apache.beehive.netui.core.urls.MutableURI, org.apache.beehive.netui.core.urls.URLRewriter.URLType, boolean).
protected  String getCurrentActionName()
          Get the name of the current action being executed.
protected  DataSource getDataSource(HttpServletRequest request)
          Return the default data source for the Struts module associated with this FlowController.
protected  DataSource getDataSource(HttpServletRequest request, String key)
          Return the specified data source for the current Struts module.
protected static Locale getDefaultLocale()
          Get the system default locale.
 ActionForm getFormBean(ActionMapping mapping)
          Get the flow-scoped form bean member associated with the given ActionMapping.
protected  Locale getLocale()
          Get the user's currently selected Locale.
protected  Locale getLocale(HttpServletRequest request)
          Deprecated. Use getLocale(javax.servlet.http.HttpServletRequest) or retrieveUserLocale(javax.servlet.http.HttpServletRequest, java.lang.String).
protected  ActionMapping getMapping()
          Deprecated. Use getActionMapping() instead.
protected  MessageResources getMessageResources()
          Get the default message resources for this FlowController.
protected  MessageResources getMessageResources(String key)
          Get the specified message resources for this FlowController.
 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.
abstract  PreviousPageInfo getPreviousPageInfoLegacy(PageFlowController curJpf, HttpServletRequest request)
          Deprecated. This method will be removed without replacement in a future release.
protected  HttpServletRequest getRequest()
          Get the current HttpServletRequest.
protected  MessageResources getResources()
          Deprecated. This method can only return the resources for the default module. Use getMessageResources() to get the resources for this FlowController.
protected  MessageResources getResources(HttpServletRequest request)
          Deprecated. Use getMessageResources() instead.
protected  MessageResources getResources(HttpServletRequest request, String key)
          Deprecated. Use getMessageResources(String) instead.
protected  HttpServletResponse getResponse()
          Get the current HttpServletResponse.
 String getRewrittenActionURI(String actionName, Map parameters, boolean asValidXml)
          Create a fully-rewritten URI given an action and parameters.
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.
 ActionForward handleException(Throwable ex, ActionMapping mapping, 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 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)
          Deprecated. This method will be removed without replacement in a future release. The normal method for cancelling in a form is to use the action attribute on Button, rather than avoiding validation on the current action.
 boolean isPageFlow()
          Tell whether this is a PageFlowController.
protected  boolean isTokenValid()
          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(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.
protected  boolean isTokenValid(HttpServletRequest request)
          Deprecated. Use isTokenValid() instead.
protected  boolean isTokenValid(HttpServletRequest request, boolean reset)
          Deprecated. Use isTokenValid(boolean) instead.
 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. This method will be removed in v1.1.
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. This method will be removed in v1.1.
protected  void onCreate()
          Callback that is invoked when this controller instance is created.
protected  void onDestroy()
          Deprecated. onDestroy(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 remove()
          Remove this instance from the user session.
protected  void resetToken()
          Reset the saved transaction token in the user's session.
protected  void resetToken(HttpServletRequest request)
          Deprecated. Use resetToken() instead.
 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 saveActionErrors(ActionMessages errors)
          Save the specified messages keys into the request for use by the <netui:error> or <netui:errors> tags.
protected  void saveErrors(HttpServletRequest request, ActionMessages errors)
          Deprecated. Use saveActionErrors(org.apache.struts.action.ActionMessages) instead.
protected  void saveMessages(HttpServletRequest request, ActionMessages messages)
          Deprecated. This method will be removed without replacement in a future release.
 void savePreviousPageInfo(ActionForward forward, ActionForm form, ActionMapping mapping, HttpServletRequest request, ServletContext servletContext, boolean isSpecialForward)
          Store information about recent pages displayed.
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(Locale).
protected  void setLocale(Locale locale)
          Deprecated. Use setLocale(Locale).
 
Methods inherited from class PageFlowManagedObject
ensureFailover, fieldIsUninitialized, getDisplayName, getServletContext, initializeField, persistInSession, removeFromSession, 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

public ActionForward handleException(Throwable ex,
                                     ActionMapping mapping,
                                     ActionForm form,
                                     HttpServletRequest request,
                                     HttpServletResponse response)
                              throws IOException,
                                     ServletException
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.
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:
ServletException - if another Exception is thrown during handling of ex.
IOException

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

create

public void create(HttpServletRequest request,
                   HttpServletResponse response,
                   ServletContext servletContext)
Description copied from class: PageFlowManagedObject
Initialize.

Overrides:
create in class PageFlowManagedObject

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(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(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

getPreviousPageInfoLegacy

public abstract PreviousPageInfo getPreviousPageInfoLegacy(PageFlowController curJpf,
                                                           HttpServletRequest request)
Deprecated. This method will be removed without replacement in a future release.

Get a legacy PreviousPageInfo.


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 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 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. This method will be removed in v1.1.

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. This method will be removed in v1.1.

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 FlowController.
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 FlowController.
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.


remove

protected void remove()
Remove this instance from the user session.


savePreviousPageInfo

public void savePreviousPageInfo(ActionForward forward,
                                 ActionForm form,
                                 ActionMapping mapping,
                                 HttpServletRequest request,
                                 ServletContext servletContext,
                                 boolean isSpecialForward)
Store information about recent pages displayed. Usually should not be called directly.


alwaysTrackPreviousAction

protected boolean alwaysTrackPreviousAction()
When this FlowController does not use a Jpf.Forward annotation with a navigateTo=Jpf.NavigateTo.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.getPreviousFormBean()

alwaysTrackPreviousPage

protected boolean alwaysTrackPreviousPage()
When this FlowController does not use a Jpf.Forward annotation with either a navigateTo=Jpf.NavigateTo.currentPage attribute or a navigateTo=Jpf.NavigateTo.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 message,
                                            Object formBean,
                                            ActionForm wrappedFormBean,
                                            ActionMapping actionMapping,
                                            HttpServletRequest request,
                                            HttpServletResponse response,
                                            boolean readonly)
                                     throws IOException,
                                            ServletException
Invoke the given exception handler method.

Parameters:
method - the action handler method to invoke.
ex - the Throwable that is to be handled.
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:
IOException
ServletException

addActionError

public void addActionError(String propertyName,
                           String messageKey,
                           Object... messageArgs)
Add a property-related message 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 message.
messageArgs - zero or more arguments to the message.

addActionErrorExpression

public void addActionErrorExpression(String propertyName,
                                     String expression,
                                     Object... messageArgs)
Add a property-related message as an expression that will be evaluated and shown with the Errors and Error tags.

Parameters:
propertyName - the name of the property with which to associate this error.
expression - the expression that will be evaluated to generate the error message.
messageArgs - zero or more arguments to the message.

addValidationError

protected void addValidationError(String propertyName,
                                  String messageKey,
                                  Object[] messageArgs)
Deprecated. Use addActionError(java.lang.String, java.lang.String, java.lang.Object...) instead.

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)
Deprecated. Use addActionError(java.lang.String, java.lang.String, java.lang.Object...) instead.

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.

getDataSource

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

Parameters:
request - the current request.

getDataSource

protected DataSource getDataSource(HttpServletRequest request,
                                   String key)
Return the specified data source for the current Struts 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(javax.servlet.http.HttpServletRequest) or retrieveUserLocale(javax.servlet.http.HttpServletRequest, java.lang.String).

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()
Get 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 getMessageResources() to get the resources for this FlowController.

Return the message resources for the default module.


getResources

protected MessageResources getResources(HttpServletRequest request)
Deprecated. Use getMessageResources() instead.

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)
Deprecated. Use getMessageResources(String) instead.

Return the specified message resources for the current module.

Parameters:
request - the current request.
key - The bundle key specified in a Jpf.MessageBundle annotation.

getMessageResources

protected MessageResources getMessageResources()
Get the default message resources for this FlowController.


getMessageResources

protected MessageResources getMessageResources(String key)
Get the specified message resources for this FlowController.

Parameters:
key - The bundle key specified in a Jpf.MessageBundle annotation.

isCancelled

protected boolean isCancelled(HttpServletRequest request)
Deprecated. This method will be removed without replacement in a future release. The normal method for cancelling in a form is to use the action attribute on Button, rather than avoiding validation on the current action.

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 the Struts 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

generateToken

protected String generateToken(HttpServletRequest request)
Deprecated. Use generateToken() instead.

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

Parameters:
request - the current request.

generateToken

protected String generateToken()
Generate a new transaction token, to be used for enforcing a single request for a particular transaction.

See Also:
isTokenValid(), isTokenValid(boolean), resetToken()

isTokenValid

protected boolean isTokenValid(HttpServletRequest request)
Deprecated. Use isTokenValid() instead.

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()
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:

See Also:
generateToken(), resetToken()

isTokenValid

protected boolean isTokenValid(HttpServletRequest request,
                               boolean reset)
Deprecated. Use isTokenValid(boolean) instead.

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?

isTokenValid

protected boolean isTokenValid(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:
reset - Should we reset the token after checking it?
See Also:
generateToken(), resetToken()

resetToken

protected void resetToken(HttpServletRequest request)
Deprecated. Use resetToken() instead.

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

resetToken

protected void resetToken()
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.

See Also:
isTokenValid(), isTokenValid(boolean), generateToken()

saveErrors

protected void saveErrors(HttpServletRequest request,
                          ActionMessages errors)
Deprecated. Use saveActionErrors(org.apache.struts.action.ActionMessages) instead.

Save the specified messages keys into the request for use by the <netui:error> or <netui:errors> tags.

Parameters:
errors - the ActionMessages to save in the request.

saveMessages

protected void saveMessages(HttpServletRequest request,
                            ActionMessages messages)
Deprecated. This method will be removed without replacement in a future release.

Save the specified messages keys into the appropriate request attribute for use by the Struts <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

saveActionErrors

protected void saveActionErrors(ActionMessages errors)
Save the specified messages keys into the request for use by the <netui:error> or <netui:errors> tags.

Parameters:
errors - the ActionMessages to save in the request.

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(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)
Deprecated. Use setLocale(Locale).

Set the user's currently selected Locale.

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

getFormBean

public ActionForm getFormBean(ActionMapping mapping)
Get the flow-scoped form bean member associated with the given ActionMapping.


getActionURI

public MutableURI getActionURI(String actionName)
                        throws URISyntaxException
Create a raw action URI, which can be modified before being sent through the registered URL rewriting chain using URLRewriterService.rewriteURL(javax.servlet.ServletContext, javax.servlet.ServletRequest, javax.servlet.ServletResponse, org.apache.beehive.netui.core.urls.MutableURI, org.apache.beehive.netui.core.urls.URLRewriter.URLType, boolean).

Parameters:
actionName - the action name to convert into a MutableURI.
Returns:
a MutableURI for the given action, suitable for URL rewriting.
Throws:
URISyntaxException - if there is a problem converting the action URI (derived from processing the given action name) into a MutableURI.
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().

getRewrittenActionURI

public String getRewrittenActionURI(String actionName,
                                    Map parameters,
                                    boolean asValidXml)
                             throws URISyntaxException
Create a fully-rewritten URI given an action and parameters.

Parameters:
actionName - the action name to convert into a fully-rewritten URI.
parameters - the additional parameters to include in the URI query.
asValidXml - flag indicating that the query of the uri should be written using the "&" entity, rather than the character, '&'.
Returns:
a fully-rewritten URI for the given action.
Throws:
URISyntaxException - if there is a problem converting the action url (derived from processing the given action name) into a URI.
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().