PageFlowUtils Class

com.bea.wlw.netui.pageflow
PageFlowUtils Class

public class PageFlowUtils

    extends Object
    implements PageFlowConstants

str Utility methods related to Page Flow.


Hierarchy
Object
  PageFlowUtils
All Implemented Interfaces

PageFlowConstants

Constructor Summary

PageFlowUtils()

 

Method Summary

public static void
addPageInput(String name, Object value, ServletRequest request)
Sett a named page input, which corresponds to an input declared by the pageInput JSP tag.
public static void
addValidationError(String propertyName, String messageKey, Object[] messageArgs, ServletRequest request)
Add a validation error that will be shown with the Errors and Error tags.
public static void
addValidationError(String propertyName, String messageKey, Object messageArg, ServletRequest request)
Add a validation error that will be shown with the Errors and Error tags.
public static void
addValidationError(String propertyName, String messageKey, ServletRequest request)
Add a validation error that will be shown with the Errors and Error tags.
public static void
destroyPageFlowStack(HttpServletRequest request)
Destroys the stack of PageFlowControllers that have invoked nested page flows.
public static void
dumpRequest(HttpServletRequest request, PrintStream output)
Print parameters and attributes in the given request.
public static void
dumpServletContext(ServletContext context, PrintStream output)
Print attributes in the given ServletContext.
public static final PageFlowController
ensureCurrentPageFlow(HttpServletRequest request, HttpServletResponse response, ServletContext context)
Get or create the current PageFlowConroller for the given request.
public static GlobalApp
ensureGlobalApp(HttpServletRequest request, HttpServletResponse response)
Get or create the current GlobalApp instance.
public static GlobalApp
ensureGlobalApp(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
Get or create the current GlobalApp instance.
public static String
getActionURI(ServletRequest request)
Get the most recent action URI that was processed by FlowController.execute(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse).
public static String
getBeginActionURI(String requestURI)
Get a URI for the "begin" action in the PageFlowController associated with the given request URI.
public static ActionResolver
getCurrentActionResolver(HttpServletRequest request)
Get the current ActionResolver (PageFlowController).
public static final PageFlowController
getCurrentPageFlow(HttpServletRequest request)
Get the current PageFlowController.
public static String
getFileExtension(String filename)
Get the file extension from a file name.
public static String
getFormBeanName(ActionForm formInstance, HttpServletRequest request)
Get the name for the type of a ActionForm instance.
public static String
getFormBeanName(Class formBeanClass, HttpServletRequest request)
Get the name for an ActionForm type.
public static GlobalApp
getGlobalApp(HttpServletRequest request)
Get the current GlobalApp instance.
public static String
getJpfClassName(String uri)
Get the class name of a PageFlowController, given the URI to it.
public static String
getModuleConfPath(String modulePath)
public static String
getModulePath(HttpServletRequest request, String requestURI)
Get the Struts module path for a URI.
public static String
getModulePath(HttpServletRequest request)
Get the Struts module path for the current request URI.
public static String
getModulePathForRelativeURI(String uri)
Get the Struts module path for a URI that is relative to the web application root.
public static PageFlowController
getNestingPageFlow(HttpServletRequest request)
Get the PageFlowController that is nesting the current one.
public static final Stack
getPageFlowStack(HttpServletRequest request)
Get the stack of nested pageflows for the current user session.
public static String
getPageFlowURI(String className)
Get the URI for a PageFlowController, given its class name.
public static Object
getPageInput(String name, ServletRequest request)
Get a named page input that was registered in the current request.
public static final String
getRelativeURI(HttpServletRequest request, PageFlowController relativeTo)
Get the request URI, relative to the URI of the given PageFlowController.
public static final String
getRelativeURI(HttpServletRequest request, String uri, PageFlowController relativeTo)
Get a URI relative to the URI of the given PageFlowController.
public static boolean
isAbsoluteURI(String uri)
Tell whether a given URI is absolute, i.e., whether it contains a scheme-part (e.g., "http:").
public static Boolean
isSecureResource(String uri, ServletContext context, HttpServletRequest request)
Tell whether a web application resource requires a secure transport protocol.
public static Boolean
isSecureResource(String uri, ServletContext context)
public static void
preventCache(HttpServletResponse response)
Set response headers to prevent caching of the response by the browser.
public static void
setCurrentActionResolver(ActionResolver resolver, HttpServletRequest request)
Set the current ActionResolver (PageFlowController) in the user session.
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).
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).
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).
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).
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).
public 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.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   

Constructor Detail

PageFlowUtils

public PageFlowUtils()
 

Method Detail

addPageInput(String, Object, ServletRequest) Method

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

Parameters

name
the name of hte page input.
value
the value of the page input.
request
the current ServletRequest.

addValidationError(String, String, Object[], ServletRequest) Method

public static void addValidationError(String propertyName, 
                                      String messageKey, 
                                      Object[] messageArgs, 
                                      ServletRequest request)
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(String, String, Object, ServletRequest) Method

public static void addValidationError(String propertyName, 
                                      String messageKey, 
                                      Object messageArg, 
                                      ServletRequest request)
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(String, String, ServletRequest) Method

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

destroyPageFlowStack(HttpServletRequest) Method

public static void destroyPageFlowStack(HttpServletRequest request)
Destroys the stack of PageFlowControllers that have invoked nested page flows.

Parameters

request
the current HttpServletRequest.

dumpRequest(HttpServletRequest, PrintStream) Method

public static void dumpRequest(HttpServletRequest request, 
                               PrintStream output)
Print parameters and attributes in the given request.

Parameters

request
the current HttpServletRequest.
output
a PrintStream to which to output request parameters and request/session attributes; if null, System.err is used.

dumpServletContext(ServletContext, PrintStream) Method

public static void dumpServletContext(ServletContext context, 
                                      PrintStream output)
Print attributes in the given ServletContext.

Parameters

context
the current ServletContext.
output
a PrintStream to which to output ServletContext attributes; if null, System.err is used.

ensureCurrentPageFlow(HttpServletRequest, HttpServletResponse, ServletContext) Method

public static final PageFlowController ensureCurrentPageFlow(HttpServletRequest request, 
                                                             HttpServletResponse response, 
                                                             ServletContext context)
Get or create the current PageFlowConroller for the given request.

Parameters

request
the current HttpServletRequest.
response
the current HttpServletResponse.
context
the current ServletContext.

Returns

the current PageFlowController in the user session, or if there is none, create one appropriate to the given request if possible. Failing that, return null.

ensureGlobalApp(HttpServletRequest, HttpServletResponse) Method

public static GlobalApp ensureGlobalApp(HttpServletRequest request, 
                                        HttpServletResponse response)
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(HttpServletRequest, HttpServletResponse, ServletContext) Method

public static GlobalApp ensureGlobalApp(HttpServletRequest request, 
                                        HttpServletResponse response, 
                                        ServletContext servletContext)
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.

getActionURI(ServletRequest) Method

public static String getActionURI(ServletRequest request)
Get the most recent action URI that was processed by FlowController.execute(ActionMapping, ActionForm, HttpServletRequest, 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.

getBeginActionURI(String) Method

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.

getCurrentActionResolver(HttpServletRequest) Method

public static ActionResolver getCurrentActionResolver(HttpServletRequest request)
Get the current ActionResolver (PageFlowController).

Returns

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

getCurrentPageFlow(HttpServletRequest) Method

public static final PageFlowController getCurrentPageFlow(HttpServletRequest request)
Get the current PageFlowController.

Parameters

request
the current HttpServletRequest.

Returns

the current PageFlowController from the user session, or null if there is none.

getFileExtension(String) Method

public static String getFileExtension(String filename)
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.

getFormBeanName(ActionForm, HttpServletRequest) Method

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(Class, HttpServletRequest) Method

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 '_'.

getGlobalApp(HttpServletRequest) Method

public static GlobalApp getGlobalApp(HttpServletRequest request)
Get the current GlobalApp instance.

Parameters

request
the current HttpServletRequest.

Returns

the current GlobalApp from the user session, or null if none exists.

getJpfClassName(String) Method

public static String getJpfClassName(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).

getModuleConfPath(String) Method

DEPRECATED Use com.bea.wlw.netui.pageflow.PageFlowActionServlet.getModuleConfPath(java.lang.String) instead. Get the path to the Struts module configration file (e.g., "/WEB-INF/.pageflow-struts-generated/jpf-struts-config-someModule") for a given module path (e.g., "someModule"), according to the PageFlow convention.

public static String getModuleConfPath(String modulePath)

Parameters

modulePath
the Struts module path.

Returns

a String that is the path to the Struts configuration file, relative to the web application root.

getModulePath(HttpServletRequest, String) Method

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(HttpServletRequest) Method

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(String) Method

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.

getNestingPageFlow(HttpServletRequest) Method

public static PageFlowController getNestingPageFlow(HttpServletRequest request)
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.

getPageFlowStack(HttpServletRequest) Method

public static final Stack getPageFlowStack(HttpServletRequest request)
Get the stack of nested pageflows for the current user session. Create and store an empty stack if none exists.

Parameters

request
the current HttpServletRequest

Returns

a PageFlowStack of nested pageflows for the current user session.

getPageFlowURI(String) Method

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

getPageInput(String, ServletRequest) Method

public static Object getPageInput(String name, 
                                  ServletRequest request)
Get a named page input that was registered in the current request.

Parameters

name
the name of the page input.
request
the current ServletRequest

Related Topics

PageFlowUtils.addPageInput(String, Object, ServletRequest)


getRelativeURI(HttpServletRequest, PageFlowController) Method

public static final 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(HttpServletRequest, String, PageFlowController) Method

public static final 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.

isAbsoluteURI(String) Method

public static boolean isAbsoluteURI(String uri)
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.

isSecureResource(String, ServletContext, HttpServletRequest) Method

public static Boolean isSecureResource(String uri, 
                                       ServletContext context, 
                                       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.
context
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(String, ServletContext) Method

DEPRECATED Use isSecureResource( String uri, ServletContext context, HttpServletRequest request ) instead. This version will not work in a portable pageflow environment.

public static Boolean isSecureResource(String uri, 
                                       ServletContext context)

Parameters

uri
a webapp-relative URI for a resource. There must not be query parameters or a scheme on the URI.
context
the ServletContext

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.

preventCache(HttpServletResponse) Method

public static void preventCache(HttpServletResponse response)
Set response headers to prevent caching of the response by the browser.

Parameters

response
the current HttpServletResponse

setCurrentActionResolver(ActionResolver, HttpServletRequest) Method

public static void setCurrentActionResolver(ActionResolver resolver, 
                                            HttpServletRequest request)
Set the current ActionResolver (PageFlowController) in the user session.

Parameters

resolver
the ActionResolver to set as the current one in the user session.
request
the current HttpServletRequest.

setOutputForm(ActionMapping, ActionForm, HttpServletRequest, boolean) Method

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).
request
if false a form from fwd will only be set in the request if there is no existing form with the same name.
overwrite
the current HttpServletRequest.

setOutputForms(ActionMapping, Forward, HttpServletRequest, boolean) Method

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(ActionMapping, Forward, HttpServletRequest) Method

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(ActionMapping, ActionForm[], HttpServletRequest) Method

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(ActionMapping, ActionForm[], HttpServletRequest, boolean) Method

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).
request
if false a form from fwd will only be set in the request if there is no existing form with the same name.
overwrite
the current HttpServletRequest.

strutsLookup(ServletContext, ServletRequest, HttpServletResponse, String, String[]) Method

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 action-name is used to construct an action URI which is set as the request URI.
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.

Exceptions

Exception