org.apache.beehive.netui.pageflow
Class PageFlowUtils

Object
  extended by PageFlowUtils
All Implemented Interfaces:
InternalConstants, PageFlowConstants

public class PageFlowUtils
extends Object
implements PageFlowConstants, InternalConstants

Utility methods related to Page Flow.


Field Summary
 
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, DEFAULT_VIEW_RENDERING_EXTENSION, 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, VIEW_RENDERER_ATTRIBUTE_NAME, VIEW_RENDERER_URI_COMMAND, VIEW_RENDERING_EXTENSION_PARAM
 
Fields inherited from interface InternalConstants
ACTION_EXTENSION_LEN, ACTION_OVERRIDE_PREFIX, ANNOTATION_QUALIFIER, ATTR_PREFIX, BACKING_CLASS_IMPLICIT_OBJECT, BEGIN_ACTION_PATH, CURRENT_JPF_ATTR, CURRENT_LONGLIVED_ATTR, FACES_BACKING_ATTR, FACES_BACKING_EXTENSION, FACES_EXTENSION, FACES_EXTENSION_DOT, GLOBALAPP_CLASSNAME, GLOBALAPP_MEMBER_NAME, GLOBALAPP_MODULE_CONTEXT_PATH, INTERNAL_VAR_PREFIX, JSF_EXTENSION, JSF_EXTENSION_DOT, MESSAGE_IS_EXPRESSION_PREFIX, MESSAGE_IS_EXPRESSION_PREFIX_LENGTH, NETUI_CONFIG_PATH, RETURN_ACTION_VIEW_RENDERER_PARAM, RETURNING_FORM_ATTR, RETURNING_FROM_NESTING_ATTR, SAVED_PREVIOUS_PAGE_INFO_ATTR, SHARED_FLOW_ATTR_PREFIX, SHARED_FLOW_EXTENSION, SHARED_FLOW_MODULE_PREFIX, SHARED_FLOW_MODULE_PREFIX_LEN, SHARED_FLOW_ROOT_MODULE, WEBINF_DIR
 
Constructor Summary
PageFlowUtils()
           
 
Method Summary
static void addActionError(ServletRequest request, String propertyName, String messageKey)
          Add a property-related message that will be shown with the Errors and Error tags.
static void addActionError(ServletRequest request, String propertyName, String messageKey, Object messageArg)
          Add a property-related message that will be shown with the Errors and Error tags.
static void addActionError(ServletRequest request, String propertyName, String messageKey, Object[] messageArgs)
          Add a property-related message that will be shown with the Errors and Error tags.
static void addActionError(ServletRequest request, String propertyName, String messageKey, Object messageArg1, Object messageArg2)
          Add a property-related message that will be shown with the Errors and Error tags.
static void addActionError(ServletRequest request, String propertyName, String messageKey, Object messageArg1, Object messageArg2, Object messageArg3)
          Add a property-related message that will be shown with the Errors and Error tags.
static void addActionErrorExpression(HttpServletRequest request, 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.
static void addActionOutput(String name, Object value, ServletRequest request)
          Set a named action output, which corresponds to an input declared by the pageInput JSP tag.
static void addBindingUpdateError(ServletRequest request, String expression, String message, Throwable e)
          Deprecated. This is an internal utility. InternalUtils.addBindingUpdateError(javax.servlet.ServletRequest, java.lang.String, java.lang.String, java.lang.Throwable) can be used, but it is not guaranteed to be supported in the future.
static void addPageInput(String name, Object value, ServletRequest request)
          Deprecated. Use addActionOutput(java.lang.String, java.lang.Object, javax.servlet.ServletRequest) instead.
static void addValidationError(String propertyName, String messageKey, Object[] messageArgs, ServletRequest request)
          Deprecated. Use addActionError(ServletRequest, String, String, Object[]) instead.
static void addValidationError(String propertyName, String messageKey, Object messageArg, ServletRequest request)
          Deprecated. Use addActionError(ServletRequest, String, String, Object[]) instead.
static void addValidationError(String propertyName, String messageKey, ServletRequest request)
          Deprecated. Use addActionError(ServletRequest, String, String, Object[]) instead.
static URLTemplatesFactory createURLTemplatesFactory(ServletContext servletContext)
          Get an uninitialized instance of a container specific URLTemplatesFactory from the ServletContainerAdapter.
static void destroyPageFlowStack(HttpServletRequest request)
          Deprecated. Use PageFlowStack.destroy(javax.servlet.http.HttpServletRequest) instead.
static void dumpRequest(HttpServletRequest request, PrintStream output)
          Deprecated. This is an internal utility. ServletUtils.dumpRequest(javax.servlet.ServletRequest, java.io.PrintStream) can be used, but it is not guaranteed to be supported in the future.
static void dumpServletContext(ServletContext context, PrintStream output)
          Deprecated. This is an internal utility. ServletUtils.dumpServletContext(javax.servlet.ServletContext, java.io.PrintStream) can be used, but it is not guaranteed to be supported in the future.
static boolean ensureAppDeployment(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Deprecated. This method no longer has any effect, and will be removed without replacement in a future release.
static PageFlowController ensureCurrentPageFlow(HttpServletRequest request, HttpServletResponse response)
          Deprecated. Use getCurrentPageFlow(javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext) instead.
static PageFlowController ensureCurrentPageFlow(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Deprecated. Use getCurrentPageFlow(javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext) instead.
static GlobalApp ensureGlobalApp(HttpServletRequest request, HttpServletResponse response)
          Deprecated. Use getGlobalApp(javax.servlet.http.HttpServletRequest) instead.
static GlobalApp ensureGlobalApp(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Deprecated. Use getSharedFlow(java.lang.String, javax.servlet.http.HttpServletRequest) instead.
static ModuleConfig ensureModuleConfig(String modulePath, ServletRequest request, ServletContext context)
          Deprecated. This is an internal utility. InternalUtils.ensureModuleConfig(java.lang.String, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future.
static Object getActionOutput(String name, ServletRequest request)
          Get a named action output that was registered in the current request.
static MutableURI getActionURI(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, 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.URLType, boolean).
static String getActionURI(ServletRequest request)
          Get the most recent action URI that was processed by FlowController.execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).
static String getBeginActionURI(String requestURI)
          Get a URI for the "begin" action in the PageFlowController associated with the given request URI.
static Map getBindingUpdateErrors(ServletRequest request)
          Deprecated. This is an internal utility. InternalUtils.getBindingUpdateErrors(javax.servlet.ServletRequest) can be used, but it is not guaranteed to be supported in the future.
static ActionResolver getCurrentActionResolver(HttpServletRequest request)
          Deprecated. Use getCurrentPageFlow(HttpServletRequest, ServletContext) instead.
static ActionResolver getCurrentActionResolver(HttpServletRequest request, ServletContext servletContext)
          Deprecated. Use getCurrentPageFlow(HttpServletRequest, ServletContext) instead.
static PageFlowController getCurrentPageFlow(HttpServletRequest request)
          Deprecated. Use getCurrentPageFlow(HttpServletRequest, ServletContext) instead.
static PageFlowController getCurrentPageFlow(HttpServletRequest request, ServletContext servletContext)
          Get the current PageFlowController.
static String getFileExtension(String filename)
          Deprecated. Use FileUtils.getFileExtension(java.lang.String) instead.
static String getFormBeanName(ActionForm formInstance, HttpServletRequest request)
          Get the name for the type of a ActionForm instance.
static String getFormBeanName(Class formBeanClass, HttpServletRequest request)
          Get the name for an ActionForm type.
static GlobalApp getGlobalApp(HttpServletRequest request)
          Deprecated. Use getSharedFlow(java.lang.String, javax.servlet.http.HttpServletRequest) instead.
static ModuleConfig getGlobalAppConfig(ServletContext servletContext)
          Deprecated. This will be removed with no replacement in a future release.
static String getJpfClassName(String uri)
          Deprecated. Use getPageFlowClassName(String) instead.
static PageFlowController getLongLivedPageFlow(String modulePath, HttpServletRequest request)
          Deprecated. Use getLongLivedPageFlow(String, HttpServletRequest, ServletContext) instead.
static PageFlowController getLongLivedPageFlow(String modulePath, HttpServletRequest request, ServletContext servletContext)
          Get the long-lived page flow instance associated with the given module (directory) path.
static ModuleConfig getModuleConfig(String modulePath, ServletContext context)
          Deprecated. This is an internal utility. InternalUtils.getModuleConfig(java.lang.String, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future.
static String getModuleConfPath(String modulePath)
          Deprecated. Use PageFlowActionServlet.getModuleConfPath(java.lang.String) instead. Get the path to the Struts module configration file (e.g., "/WEB-INF/classes/_pageflow/struts-config-someModule") for a given module path (e.g., "someModule"), according to the PageFlow convention.
static String getModulePath(HttpServletRequest request)
          Get the Struts module path for the current request URI.
static String getModulePath(HttpServletRequest request, String requestURI)
          Get the Struts module path for a URI.
static String getModulePathForRelativeURI(String uri)
          Get the Struts module path for a URI that is relative to the web application root.
static PageFlowController getNestingPageFlow(HttpServletRequest request)
          Deprecated. Use getNestingPageFlow(HttpServletRequest, ServletContext) instead.
static PageFlowController getNestingPageFlow(HttpServletRequest request, ServletContext servletContext)
          Get the PageFlowController that is nesting the current one.
static String getPageFlowClassName(String uri)
          Get the class name of a PageFlowController, given the URI to it.
static String getPageFlowClassName(String modulePath, ServletRequest request, ServletContext context)
          Deprecated. This is an internal utility. InternalUtils.getFlowControllerClassName(java.lang.String, javax.servlet.ServletRequest, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future.
static Stack getPageFlowStack(HttpServletRequest request)
          Deprecated. Use PageFlowStack.get(HttpServletRequest, ServletContext) instead.
static String getPageFlowURI(String className)
          Get the URI for a PageFlowController, given its class name.
static Object getPageInput(String name, ServletRequest request)
          Deprecated. Use getActionOutput(java.lang.String, javax.servlet.ServletRequest) instead.
static String getRelativeURI(HttpServletRequest request, PageFlowController relativeTo)
          Get the request URI, relative to the URI of the given PageFlowController.
static String getRelativeURI(HttpServletRequest request, String uri, PageFlowController relativeTo)
          Get a URI relative to the URI of the given PageFlowController.
static String getRewrittenActionURI(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, String actionName, Map params, String fragment, boolean forXML)
          Create a fully-rewritten URI given an action name and parameters.
static String getRewrittenHrefURI(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, String path, Map params, String fragment, boolean forXML)
          Create a fully-rewritten URI given a path and parameters.
static String getRewrittenResourceURI(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, String path, Map params, String fragment, boolean forXML)
          Create a fully-rewritten URI given a path and parameters.
static SecurityProtocol getSecurityProtocol(String uri, ServletContext servletContext, HttpServletRequest request)
          Tell whether a web application resource requires a secure transport protocol.
static SharedFlowController getSharedFlow(String sharedFlowClassName, HttpServletRequest request)
          Deprecated. Use getSharedFlow(String, HttpServletRequest, ServletContext) instead.
static SharedFlowController getSharedFlow(String sharedFlowClassName, HttpServletRequest request, ServletContext servletContext)
          Get the shared flow with the given class name.
static Map getSharedFlows(HttpServletRequest request)
          Get the a map of shared flow name to shared flow instance, based on the names defined in the sharedFlowRefs attribute of the @Jpf.Controller annotation on the current page flow.
static String getURLTemplateKey(URLType urlType, boolean needsToBeSecure)
          Returns a key for the URL template type given the URL type and a flag indicating a secure URL or not.
static boolean isAbsoluteURI(String uri)
          Deprecated. Use FileUtils.isAbsoluteURI(java.lang.String) instead.
static Boolean isSecureResource(String uri, ServletContext context)
          Deprecated. Use getSecurityProtocol(String, ServletContext, HttpServletRequest) instead.
static boolean needsToBeSecure(ServletContext context, ServletRequest request, String uri, boolean stripContextPath)
          Tell whether a given URI should be written to be secure.
static void preventCache(HttpServletResponse response)
          Deprecated. Use ServletUtils.preventCache(javax.servlet.ServletResponse) instead.
static void removeLongLivedPageFlow(String modulePath, HttpServletRequest request)
          Deprecated. Use removeLongLivedPageFlow(String, HttpServletRequest, ServletContext) instead.
static void removeLongLivedPageFlow(String modulePath, HttpServletRequest request, ServletContext servletContext)
          Remove a "long-lived" page flow from the session.
static void removeSharedFlow(String sharedFlowClassName, HttpServletRequest request)
          Deprecated. Use removeSharedFlow(String, HttpServletRequest, ServletContext) instead.
static void removeSharedFlow(String sharedFlowClassName, HttpServletRequest request, ServletContext servletContext)
          Destroy the current SharedFlowController of the given class name.
static void setCurrentActionResolver(ActionResolver resolver, HttpServletRequest request)
          Deprecated. This is an internal utility. InternalUtils.setCurrentActionResolver(org.apache.beehive.netui.pageflow.ActionResolver, javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future. This method will be removed in the next version.
static void setOutputForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, boolean overwrite)
          Make a form bean available as an attributet in the request/session (as appropriate).
static void setOutputForms(ActionMapping mapping, ActionForm[] outputForms, HttpServletRequest request)
          Make a set of form beans available as attributets in the request/session (as appropriate).
static void setOutputForms(ActionMapping mapping, ActionForm[] outputForms, HttpServletRequest request, boolean overwrite)
          Make a set of form beans available as attributets in the request/session (as appropriate).
static void setOutputForms(ActionMapping mapping, Forward fwd, HttpServletRequest request)
          Make any form beans in the given Forward object available as attributets in the request/session (as appropriate).
static void setOutputForms(ActionMapping mapping, Forward fwd, HttpServletRequest request, boolean overwrite)
          Make any form beans in the given Forward object available as attributets in the request/session (as appropriate).
static ActionResult strutsLookup(ServletContext context, ServletRequest request, HttpServletResponse response, String actionOverride, String[] autoResolveExtensions)
          Resolve the given action to a URI by running an entire request-processing cycle on the given ScopedRequest and ScopedResponse.
static HttpServletRequest unwrapMultipart(HttpServletRequest request)
          If the given request is a MultipartRequestWrapper (Struts class that doesn't extend HttpServletRequestWrapper), return the wrapped request; otherwise, return the given request.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageFlowUtils

public PageFlowUtils()
Method Detail

getModulePath

public static String getModulePath(HttpServletRequest request,
                                   String requestURI)
Get the Struts module path for a URI. This is the parent directory, relative to the web application root, of the file referenced by the URI.

Parameters:
request - the current HttpServletRequest.
requestURI - the URI for which to get the Struts module path.

getModulePath

public static String getModulePath(HttpServletRequest request)
Get the Struts module path for the current request URI. This is the parent directory, relative to the web application root, of the file referenced by the request URI.

Parameters:
request - the current HttpServletRequest.

getModulePathForRelativeURI

public static String getModulePathForRelativeURI(String uri)
Get the Struts module path for a URI that is relative to the web application root.

Parameters:
uri - the URI for which to get the module path.

getRelativeURI

public static String getRelativeURI(HttpServletRequest request,
                                    PageFlowController relativeTo)
Get the request URI, relative to the URI of the given PageFlowController.

Parameters:
request - the current HttpServletRequest.
relativeTo - a PageFlowController to which the returned URI should be relative, or null if the returned URI should be relative to the webapp root.

getRelativeURI

public static String getRelativeURI(HttpServletRequest request,
                                    String uri,
                                    PageFlowController relativeTo)
Get a URI relative to the URI of the given PageFlowController.

Parameters:
request - the current HttpServletRequest.
uri - the URI which should be made relative.
relativeTo - a PageFlowController to which the returned URI should be relative, or null if the returned URI should be relative to the webapp root.

getBeginActionURI

public static String getBeginActionURI(String requestURI)
Get a URI for the "begin" action in the PageFlowController associated with the given request URI.

Returns:
a String that is the URI for the "begin" action in the PageFlowController associated with the given request URI.

getPageFlowStack

public static Stack getPageFlowStack(HttpServletRequest request)
Deprecated. Use PageFlowStack.get(HttpServletRequest, ServletContext) instead.

Get the stack of nested page flows for the current user session. Create and store an empty stack if none exists.

Parameters:
request - the current HttpServletRequest
Returns:
a PageFlowStack of nested page flows (PageFlowControllers) for the current user session.

destroyPageFlowStack

public static void destroyPageFlowStack(HttpServletRequest request)
Deprecated. Use PageFlowStack.destroy(javax.servlet.http.HttpServletRequest) instead.

Destroys the stack of PageFlowControllers that have invoked nested page flows.

Parameters:
request - the current HttpServletRequest.

getNestingPageFlow

public static PageFlowController getNestingPageFlow(HttpServletRequest request)
Deprecated. Use getNestingPageFlow(HttpServletRequest, ServletContext) instead.

Get the PageFlowController that is nesting the current one.

Parameters:
request - the current HttpServletRequest.
Returns:
the nesting PageFlowController, or null if the current one is not being nested.

getNestingPageFlow

public static PageFlowController getNestingPageFlow(HttpServletRequest request,
                                                    ServletContext servletContext)
Get the PageFlowController that is nesting the current one.

Parameters:
request - the current HttpServletRequest.
servletContext - the current ServletContext.
Returns:
the nesting PageFlowController, or null if the current one is not being nested.

getCurrentPageFlow

public static PageFlowController getCurrentPageFlow(HttpServletRequest request,
                                                    ServletContext servletContext)
Get the current PageFlowController.

Parameters:
request - the current HttpServletRequest.
servletContext - the current ServletContext.
Returns:
the current PageFlowController from the user session, or null if there is none.

getCurrentPageFlow

public static PageFlowController getCurrentPageFlow(HttpServletRequest request)
Deprecated. Use getCurrentPageFlow(HttpServletRequest, ServletContext) instead.

/** Get the current PageFlowController.

Parameters:
request - the current HttpServletRequest.
Returns:
the current PageFlowController from the user session, or null if there is none.

getCurrentActionResolver

public static ActionResolver getCurrentActionResolver(HttpServletRequest request)
Deprecated. Use getCurrentPageFlow(HttpServletRequest, ServletContext) instead.

Get the current ActionResolver.

Returns:
the current ActionResolver from the user session, or null if there is none.

getCurrentActionResolver

public static ActionResolver getCurrentActionResolver(HttpServletRequest request,
                                                      ServletContext servletContext)
Deprecated. Use getCurrentPageFlow(HttpServletRequest, ServletContext) instead.

Get the current ActionResolver.

Parameters:
request - the current HttpServletRequest.
servletContext - the current ServletContext.
Returns:
the current ActionResolver from the user session, or null if there is none.

getGlobalApp

public static GlobalApp getGlobalApp(HttpServletRequest request)
Deprecated. Use getSharedFlow(java.lang.String, javax.servlet.http.HttpServletRequest) instead.

Get the current GlobalApp instance.

Parameters:
request - the current HttpServletRequest.
Returns:
the current GlobalApp from the user session, or null if none exists.

getSharedFlows

public static Map getSharedFlows(HttpServletRequest request)
Get the a map of shared flow name to shared flow instance, based on the names defined in the sharedFlowRefs attribute of the @Jpf.Controller annotation on the current page flow.

Parameters:
request - the current HttpServletRequest, which is used to determine the current page flow.
Returns:
a Map of shared flow name (string) to shared flow instance (SharedFlowController).

getSharedFlow

public static SharedFlowController getSharedFlow(String sharedFlowClassName,
                                                 HttpServletRequest request)
Deprecated. Use getSharedFlow(String, HttpServletRequest, ServletContext) instead.

Get the shared flow with the given class name.

Parameters:
sharedFlowClassName - the class name of the shared flow to retrieve.
request - the current HttpServletRequest.
Returns:
the SharedFlowController of the given class name which is stored in the user session.

getSharedFlow

public static SharedFlowController getSharedFlow(String sharedFlowClassName,
                                                 HttpServletRequest request,
                                                 ServletContext servletContext)
Get the shared flow with the given class name.

Parameters:
sharedFlowClassName - the class name of the shared flow to retrieve.
request - the current HttpServletRequest.
Returns:
the SharedFlowController of the given class name which is stored in the user session.

removeSharedFlow

public static void removeSharedFlow(String sharedFlowClassName,
                                    HttpServletRequest request)
Deprecated. Use removeSharedFlow(String, HttpServletRequest, ServletContext) instead.

Destroy the current SharedFlowController of the given class name.

Parameters:
sharedFlowClassName - the class name of the current SharedFlowController to destroy.
request - the current HttpServletRequest.

removeSharedFlow

public static void removeSharedFlow(String sharedFlowClassName,
                                    HttpServletRequest request,
                                    ServletContext servletContext)
Destroy the current SharedFlowController of the given class name.

Parameters:
sharedFlowClassName - the class name of the current SharedFlowController to destroy.
request - the current HttpServletRequest.

removeLongLivedPageFlow

public static void removeLongLivedPageFlow(String modulePath,
                                           HttpServletRequest request)
Deprecated. Use removeLongLivedPageFlow(String, HttpServletRequest, ServletContext) instead.

Remove a "long-lived" page flow from the session. Once it is created, a long-lived page flow is never removed from the session unless this method or FlowController.remove() is called. Navigating to another page flow hides the current long-lived controller, but does not remove it.


removeLongLivedPageFlow

public static void removeLongLivedPageFlow(String modulePath,
                                           HttpServletRequest request,
                                           ServletContext servletContext)
Remove a "long-lived" page flow from the session. Once it is created, a long-lived page flow is never removed from the session unless this method or FlowController.remove() is called. Navigating to another page flow hides the current long-lived controller, but does not remove it.


getLongLivedPageFlow

public static PageFlowController getLongLivedPageFlow(String modulePath,
                                                      HttpServletRequest request)
Deprecated. Use getLongLivedPageFlow(String, HttpServletRequest, ServletContext) instead.

Get the long-lived page flow instance associated with the given module (directory) path.

Parameters:
modulePath - the webapp-relative path to the directory containing the long-lived page flow.
request - the current HttpServletRequest.
Returns:
the long-lived page flow instance associated with the given module, or null if none is found.

getLongLivedPageFlow

public static PageFlowController getLongLivedPageFlow(String modulePath,
                                                      HttpServletRequest request,
                                                      ServletContext servletContext)
Get the long-lived page flow instance associated with the given module (directory) path.

Parameters:
modulePath - the webapp-relative path to the directory containing the long-lived page flow.
request - the current HttpServletRequest.
servletContext - the current ServletContext.
Returns:
the long-lived page flow instance associated with the given module, or null if none is found.

setOutputForms

public static void setOutputForms(ActionMapping mapping,
                                  Forward fwd,
                                  HttpServletRequest request,
                                  boolean overwrite)
Make any form beans in the given Forward object available as attributets in the request/session (as appropriate).

Parameters:
mapping - the ActionMapping for the current Struts action being processed.
fwd - the Forward object that contains the ActionForm instances to be made available in the request/session (as appropriate).
request - the current HttpServletRequest.
overwrite - if false a form from fwd will only be set in the request if there is no existing form with the same name.

setOutputForms

public static void setOutputForms(ActionMapping mapping,
                                  Forward fwd,
                                  HttpServletRequest request)
Make any form beans in the given Forward object available as attributets in the request/session (as appropriate).

Parameters:
mapping - the ActionMapping for the current Struts action being processed.
fwd - the Forward object that contains the ActionForm instances to be made available in the request/session (as appropriate).
request - the current HttpServletRequest.

setOutputForms

public static void setOutputForms(ActionMapping mapping,
                                  ActionForm[] outputForms,
                                  HttpServletRequest request)
Make a set of form beans available as attributets in the request/session (as appropriate).

Parameters:
mapping - the ActionMapping for the current Struts action being processed.
outputForms - an array of ActionForm instances to be made available in the request/session (as appropriate).
request - the current HttpServletRequest.

setOutputForms

public static void setOutputForms(ActionMapping mapping,
                                  ActionForm[] outputForms,
                                  HttpServletRequest request,
                                  boolean overwrite)
Make a set of form beans available as attributets in the request/session (as appropriate).

Parameters:
mapping - the ActionMapping for the current Struts action being processed.
outputForms - an array of ActionForm instances to be made available in the request/session (as appropriate).
overwrite - if false a form from fwd will only be set in the request if there is no existing form with the same name.
request - the current HttpServletRequest.

setOutputForm

public static void setOutputForm(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 boolean overwrite)
Make a form bean available as an attributet in the request/session (as appropriate).

Parameters:
mapping - the ActionMapping for the current Struts action being processed.
form - an ActionForm instance to be made available in the request/session (as appropriate).
overwrite - if false a form from fwd will only be set in the request if there is no existing form with the same name.
request - the current HttpServletRequest.

getFormBeanName

public static String getFormBeanName(ActionForm formInstance,
                                     HttpServletRequest request)
Get the name for the type of a ActionForm instance. Use a name looked up from the current Struts module, or, if none is found, create one.

Parameters:
formInstance - the ActionForm instance whose type will determine the name.
request - the current HttpServletRequest, which contains a reference to the current Struts module.
Returns:
the name found in the Struts module, or, if none is found, a name that is either:
  • a camel-cased version of the base class name (minus any package or outer-class qualifiers, or, if that name is already taken,
  • the full class name, with '.' and '$' replaced by '_'.

getFormBeanName

public static String getFormBeanName(Class formBeanClass,
                                     HttpServletRequest request)
Get the name for an ActionForm type. Use a name looked up from the current Struts module, or, if none is found, create one.

Parameters:
formBeanClass - the ActionForm-derived class whose type will determine the name.
request - the current HttpServletRequest, which contains a reference to the current Struts module.
Returns:
the name found in the Struts module, or, if none is found, a name that is either:
  • a camel-cased version of the base class name (minus any package or outer-class qualifiers, or, if that name is already taken,
  • the full class name, with '.' and '$' replaced by '_'.

getPageFlowClassName

public static String getPageFlowClassName(String uri)
Get the class name of a PageFlowController, given the URI to it.

Parameters:
uri - the URI to the PageFlowController, which should be relative to the web application root (i.e., it should not include the context path).

getJpfClassName

public static String getJpfClassName(String uri)
Deprecated. Use getPageFlowClassName(String) instead.

Get the class name of a PageFlowController, given the URI to it.

Parameters:
uri - the URI to the PageFlowController, which should be relative to the web application root (i.e., it should not include the context path).

getPageFlowURI

public static String getPageFlowURI(String className)
Get the URI for a PageFlowController, given its class name.

Parameters:
className - the name of the PageFlowController class.
Returns:
a String that is the URI for the PageFlowController, relative to the web application root (i.e., not including the context path).

getModuleConfPath

public static String getModuleConfPath(String modulePath)
Deprecated. Use PageFlowActionServlet.getModuleConfPath(java.lang.String) instead. Get the path to the Struts module configration file (e.g., "/WEB-INF/classes/_pageflow/struts-config-someModule") for a given module path (e.g., "someModule"), according to the PageFlow convention.

Parameters:
modulePath - the Struts module path.
Returns:
a String that is the path to the Struts configuration file, relative to the web application root.

getActionURI

public static String getActionURI(ServletRequest request)
Get the most recent action URI that was processed by FlowController.execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).

Parameters:
request - the current ServletRequest.
Returns:
a String that is the most recent action URI. This is only valid during a request that has been forwarded from the action URI.

getSecurityProtocol

public static SecurityProtocol getSecurityProtocol(String uri,
                                                   ServletContext servletContext,
                                                   HttpServletRequest request)
Tell whether a web application resource requires a secure transport protocol. This is determined from web.xml; for example, the following block specifies that all resources under /login require a secure transport protocol.
    <security-constraint>
        <web-resource-collection>
          <web-resource-name>Secure PageFlow - begin</web-resource-name> 
          <url-pattern>/login/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
           <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
 

Parameters:
uri - a webapp-relative URI for a resource. There must not be query parameters or a scheme on the URI.
request - the current request.
Returns:
Boolean.TRUE if a transport-guarantee of CONFIDENTIAL or INTEGRAL is associated with the given resource; Boolean.FALSE a transport-guarantee of NONE is associated with the given resource; or null if there is no transport-guarantee associated with the given resource.

isSecureResource

public static Boolean isSecureResource(String uri,
                                       ServletContext context)
Deprecated. Use getSecurityProtocol(String, ServletContext, HttpServletRequest) instead.


addPageInput

public static void addPageInput(String name,
                                Object value,
                                ServletRequest request)
Deprecated. Use addActionOutput(java.lang.String, java.lang.Object, javax.servlet.ServletRequest) instead.

Set a named action output, which corresponds to an input declared by the pageInput JSP tag. The actual value can be read from within a JSP using the "pageInput" databinding context.

Parameters:
name - the name of the action output.
value - the value of the action output.
request - the current ServletRequest.

addActionOutput

public static void addActionOutput(String name,
                                   Object value,
                                   ServletRequest request)
Set a named action output, which corresponds to an input declared by the pageInput JSP tag. The actual value can be read from within a JSP using the "pageInput" databinding context.

Parameters:
name - the name of the action output.
value - the value of the action output.
request - the current ServletRequest.

getPageInput

public static Object getPageInput(String name,
                                  ServletRequest request)
Deprecated. Use getActionOutput(java.lang.String, javax.servlet.ServletRequest) instead.

Get a named action output that was registered in the current request.

Parameters:
name - the name of the action output.
request - the current ServletRequest
See Also:
addActionOutput(java.lang.String, java.lang.Object, javax.servlet.ServletRequest)

getActionOutput

public static Object getActionOutput(String name,
                                     ServletRequest request)
Get a named action output that was registered in the current request.

Parameters:
name - the name of the action output.
request - the current ServletRequest
See Also:
addActionOutput(java.lang.String, java.lang.Object, javax.servlet.ServletRequest)

addValidationError

public static void addValidationError(String propertyName,
                                      String messageKey,
                                      Object[] messageArgs,
                                      ServletRequest request)
Deprecated. Use addActionError(ServletRequest, String, String, 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.
request - the current ServletRequest.

addValidationError

public static void addValidationError(String propertyName,
                                      String messageKey,
                                      Object messageArg,
                                      ServletRequest request)
Deprecated. Use addActionError(ServletRequest, String, String, 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.
messageArg - an argument for the error message.
request - the current ServletRequest.

addValidationError

public static void addValidationError(String propertyName,
                                      String messageKey,
                                      ServletRequest request)
Deprecated. Use addActionError(ServletRequest, String, String, 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.
request - the current ServletRequest.

addActionError

public static void addActionError(ServletRequest request,
                                  String propertyName,
                                  String messageKey,
                                  Object[] messageArgs)
Add a property-related message that will be shown with the Errors and Error tags.

Parameters:
request - the current ServletRequest.
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.

addActionError

public static void addActionError(ServletRequest request,
                                  String propertyName,
                                  String messageKey)
Add a property-related message that will be shown with the Errors and Error tags.

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

addActionError

public static void addActionError(ServletRequest request,
                                  String propertyName,
                                  String messageKey,
                                  Object messageArg)
Add a property-related message that will be shown with the Errors and Error tags.

Parameters:
request - the current ServletRequest.
propertyName - the name of the property with which to associate this error.
messageKey - the message-resources key for the message.
messageArg - an argument to the message

addActionError

public static void addActionError(ServletRequest request,
                                  String propertyName,
                                  String messageKey,
                                  Object messageArg1,
                                  Object messageArg2)
Add a property-related message that will be shown with the Errors and Error tags.

Parameters:
request - the current ServletRequest.
propertyName - the name of the property with which to associate this error.
messageKey - the message-resources key for the message.
messageArg1 - the first argument to the message
messageArg2 - the second argument to the message

addActionError

public static void addActionError(ServletRequest request,
                                  String propertyName,
                                  String messageKey,
                                  Object messageArg1,
                                  Object messageArg2,
                                  Object messageArg3)
Add a property-related message that will be shown with the Errors and Error tags.

Parameters:
request - the current ServletRequest.
propertyName - the name of the property with which to associate this error.
messageKey - the message-resources key for the message.
messageArg1 - the first argument to the message
messageArg2 - the second argument to the message
messageArg3 - the third argument to the message

addActionErrorExpression

public static void addActionErrorExpression(HttpServletRequest request,
                                            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:
request - the current ServletRequest.
propertyName - the name of the property with which to associate this error.
expression - the JSP 2.0-style expression (e.g., ${pageFlow.myProperty}) or literal string that will be used as the message.
messageArgs - zero or more arguments to the message.

strutsLookup

public static ActionResult strutsLookup(ServletContext context,
                                        ServletRequest request,
                                        HttpServletResponse response,
                                        String actionOverride,
                                        String[] autoResolveExtensions)
                                 throws Exception
Resolve the given action to a URI by running an entire request-processing cycle on the given ScopedRequest and ScopedResponse.

Parameters:
context - the current ServletContext
request - the ServletRequest, which must be a ScopedRequest.
response - the ServletResponse, which must be a ScopedResponse.
actionOverride - if not null, this qualified action-path is used to construct an action URI which is set as the request URI. The action-path must begin with '/', which makes it qualified from the webapp root.
autoResolveExtensions - a list of URI extensions (e.g., ".do", ".jpf") that will be auto-resolved, i.e., on which this method will be recursively called. If null, the default extensions ".do" and ".jpf" will be used.
Throws:
Exception

unwrapMultipart

public static HttpServletRequest unwrapMultipart(HttpServletRequest request)
If the given request is a MultipartRequestWrapper (Struts class that doesn't extend HttpServletRequestWrapper), return the wrapped request; otherwise, return the given request.


ensureGlobalApp

public static GlobalApp ensureGlobalApp(HttpServletRequest request,
                                        HttpServletResponse response)
Deprecated. Use getGlobalApp(javax.servlet.http.HttpServletRequest) instead.

Get or create the current GlobalApp instance.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse
Returns:
the current GlobalApp from the user session, or a newly-instantiated one (based on the user's Global.app file) if none was in the session. Failing that, return null.

ensureGlobalApp

public static GlobalApp ensureGlobalApp(HttpServletRequest request,
                                        HttpServletResponse response,
                                        ServletContext servletContext)
Deprecated. Use getSharedFlow(java.lang.String, javax.servlet.http.HttpServletRequest) instead.

Get or create the current GlobalApp instance.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse
Returns:
the current GlobalApp from the user session, or a newly-instantiated one (based on the user's Global.app file) if none was in the session. Failing that, return null.

getBindingUpdateErrors

public static Map getBindingUpdateErrors(ServletRequest request)
Deprecated. This is an internal utility. InternalUtils.getBindingUpdateErrors(javax.servlet.ServletRequest) can be used, but it is not guaranteed to be supported in the future.


ensureModuleConfig

public static ModuleConfig ensureModuleConfig(String modulePath,
                                              ServletRequest request,
                                              ServletContext context)
Deprecated. This is an internal utility. InternalUtils.ensureModuleConfig(java.lang.String, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future.


getGlobalAppConfig

public static ModuleConfig getGlobalAppConfig(ServletContext servletContext)
Deprecated. This will be removed with no replacement in a future release.


getModuleConfig

public static ModuleConfig getModuleConfig(String modulePath,
                                           ServletContext context)
Deprecated. This is an internal utility. InternalUtils.getModuleConfig(java.lang.String, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future.


getFileExtension

public static String getFileExtension(String filename)
Deprecated. Use FileUtils.getFileExtension(java.lang.String) instead.

Get the file extension from a file name.

Parameters:
filename - the file name.
Returns:
the file extension (everything after the last '.'), or the empty string if there is no file extension.

getPageFlowClassName

public static String getPageFlowClassName(String modulePath,
                                          ServletRequest request,
                                          ServletContext context)
Deprecated. This is an internal utility. InternalUtils.getFlowControllerClassName(java.lang.String, javax.servlet.ServletRequest, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future.


ensureAppDeployment

public static boolean ensureAppDeployment(HttpServletRequest request,
                                          HttpServletResponse response,
                                          ServletContext servletContext)
Deprecated. This method no longer has any effect, and will be removed without replacement in a future release.


isAbsoluteURI

public static boolean isAbsoluteURI(String uri)
Deprecated. Use FileUtils.isAbsoluteURI(java.lang.String) instead.

Tell whether a given URI is absolute, i.e., whether it contains a scheme-part (e.g., "http:").

Parameters:
uri - the URI to test.
Returns:
true if the given URI is absolute.

ensureCurrentPageFlow

public static final PageFlowController ensureCurrentPageFlow(HttpServletRequest request,
                                                             HttpServletResponse response,
                                                             ServletContext servletContext)
Deprecated. Use getCurrentPageFlow(javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext) instead.


ensureCurrentPageFlow

public static final PageFlowController ensureCurrentPageFlow(HttpServletRequest request,
                                                             HttpServletResponse response)
Deprecated. Use getCurrentPageFlow(javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext) instead.


addBindingUpdateError

public static void addBindingUpdateError(ServletRequest request,
                                         String expression,
                                         String message,
                                         Throwable e)
Deprecated. This is an internal utility. InternalUtils.addBindingUpdateError(javax.servlet.ServletRequest, java.lang.String, java.lang.String, java.lang.Throwable) can be used, but it is not guaranteed to be supported in the future.


dumpRequest

public static void dumpRequest(HttpServletRequest request,
                               PrintStream output)
Deprecated. This is an internal utility. ServletUtils.dumpRequest(javax.servlet.ServletRequest, java.io.PrintStream) can be used, but it is not guaranteed to be supported in the future.


dumpServletContext

public static void dumpServletContext(ServletContext context,
                                      PrintStream output)
Deprecated. This is an internal utility. ServletUtils.dumpServletContext(javax.servlet.ServletContext, java.io.PrintStream) can be used, but it is not guaranteed to be supported in the future.


preventCache

public static void preventCache(HttpServletResponse response)
Deprecated. Use ServletUtils.preventCache(javax.servlet.ServletResponse) instead.


setCurrentActionResolver

public static void setCurrentActionResolver(ActionResolver resolver,
                                            HttpServletRequest request)
Deprecated. This is an internal utility. InternalUtils.setCurrentActionResolver(org.apache.beehive.netui.pageflow.ActionResolver, javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext) can be used, but it is not guaranteed to be supported in the future. This method will be removed in the next version.


getActionURI

public static MutableURI getActionURI(ServletContext servletContext,
                                      HttpServletRequest request,
                                      HttpServletResponse response,
                                      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.URLType, boolean). Use getRewrittenActionURI(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.util.Map, java.lang.String, boolean) to get a fully-rewritten URI.

Parameters:
servletContext - the current ServletContext.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
actionName - the action name to convert into a MutableURI; may be qualified with a path from the webapp root, in which case the parent directory from the current request is not used.
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.

getRewrittenActionURI

public static String getRewrittenActionURI(ServletContext servletContext,
                                           HttpServletRequest request,
                                           HttpServletResponse response,
                                           String actionName,
                                           Map params,
                                           String fragment,
                                           boolean forXML)
                                    throws URISyntaxException
Create a fully-rewritten URI given an action name and parameters.

Parameters:
servletContext - the current ServletContext.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
actionName - the action name to convert into a fully-rewritten URI; may be qualified with a path from the webapp root, in which case the parent directory from the current request is not used.
params - the additional parameters to include in the URI query.
fragment - the fragment (anchor or location) for this url.
forXML - flag indicating that the query of the uri should be written using the "&amp;" entity, rather than the character, '&'.
Returns:
a fully-rewritten URI for the given action.
Throws:
URISyntaxException - if there is a problem converting the action URI (derived from processing the given action name) into a MutableURI.

getRewrittenResourceURI

public static String getRewrittenResourceURI(ServletContext servletContext,
                                             HttpServletRequest request,
                                             HttpServletResponse response,
                                             String path,
                                             Map params,
                                             String fragment,
                                             boolean forXML)
                                      throws URISyntaxException
Create a fully-rewritten URI given a path and parameters.

Calls the rewriter service using a type of URLType.RESOURCE.

Parameters:
servletContext - the current ServletContext.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
path - the path to process into a fully-rewritten URI.
params - the additional parameters to include in the URI query.
fragment - the fragment (anchor or location) for this URI.
forXML - flag indicating that the query of the uri should be written using the "&amp;" entity, rather than the character, '&'.
Returns:
a fully-rewritten URI for the given action.
Throws:
URISyntaxException - if there's a problem converting the action URI (derived from processing the given action name) into a MutableURI.

getRewrittenHrefURI

public static String getRewrittenHrefURI(ServletContext servletContext,
                                         HttpServletRequest request,
                                         HttpServletResponse response,
                                         String path,
                                         Map params,
                                         String fragment,
                                         boolean forXML)
                                  throws URISyntaxException
Create a fully-rewritten URI given a path and parameters.

Calls the rewriter service using a type of URLType.ACTION.

Parameters:
servletContext - the current ServletContext.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
path - the path to process into a fully-rewritten URI.
params - the additional parameters to include in the URI query.
fragment - the fragment (anchor or location) for this URI.
forXML - flag indicating that the query of the uri should be written using the "&amp;" entity, rather than the character, '&'.
Returns:
a fully-rewritten URI for the given action.
Throws:
URISyntaxException - if there's a problem converting the action URI (derived from processing the given action name) into a MutableURI.

needsToBeSecure

public static boolean needsToBeSecure(ServletContext context,
                                      ServletRequest request,
                                      String uri,
                                      boolean stripContextPath)
Tell whether a given URI should be written to be secure.

Parameters:
context - the current ServletContext.
request - the current HttpServletRequest.
uri - the URI to check.
stripContextPath - if true, strip the webapp context path from the URI before processing it.
Returns:
true when:
  • the given URI is configured in the deployment descriptor to be secure (according to SecurityProtocol), or
  • the given URI is not configured in the deployment descriptor, and the current request is secure (ServletRequest.isSecure() returns true).
false when:
  • the given URI is configured explicitly in the deployment descriptor to be unsecure (according to SecurityProtocol), or
  • the given URI is not configured in the deployment descriptor, and the current request is unsecure (ServletRequest.isSecure() returns false).

getURLTemplateKey

public static String getURLTemplateKey(URLType urlType,
                                       boolean needsToBeSecure)
Returns a key for the URL template type given the URL type and a flag indicating a secure URL or not.

Parameters:
urlType - the type of URL (ACTION, RESOURCE).
needsToBeSecure - indicates that the template should be for a secure URL.
Returns:
the key/type of template to use.

createURLTemplatesFactory

public static URLTemplatesFactory createURLTemplatesFactory(ServletContext servletContext)
Get an uninitialized instance of a container specific URLTemplatesFactory from the ServletContainerAdapter. If none exists, this returns an instance of DefaultURLTemplatesFactory. Caller should then set the known and required tokens, call the URLTemplatesFactory.load(javax.servlet.ServletContext) method and URLTemplatesFactory.initServletContext(javax.servlet.ServletContext, org.apache.beehive.netui.core.urltemplates.URLTemplatesFactory).

IMPORTANT NOTE - Always try to get the application instance from the ServletContext by calling URLTemplatesFactory.getURLTemplatesFactory(javax.servlet.ServletContext). Then, if a new URLTemplatesFactory must be created, call this method.

Parameters:
servletContext -
Returns:
a container specific implementation of URLTemplatesFactory, or DefaultURLTemplatesFactory.