| java.lang.Object org.apache.velocity.tools.struts.StrutsUtils
StrutsUtils | public class StrutsUtils (Code) | | A utility class to expose the Struts shared
resources. All methods are static.
This class is provided for use by Velocity view tools
that need access to Struts resources. By having all Struts-
specific code in this utility class, maintenance is simplified
and reuse fostered.
It is the aim, that sooner or later the functionality in
this class is integrated into Struts itself. See
Bug #16814
for more on that.
author: Marino A. Jonsson author: Nathan Bubna author: Gabe Sidler author: based on code by Ted Husted version: $Id: StrutsUtils.java 479724 2006-11-27 18:49:37Z nbubna $ |
Method Summary | |
public static String | errorMarkup(String property, HttpServletRequest request, HttpSession session, ServletContext application) Returns a formatted error message. | public static String | errorMarkup(String property, String bundle, HttpServletRequest request, HttpSession session, ServletContext application) Returns a formatted error message. | public static ActionForm | getActionForm(HttpServletRequest request, HttpSession session) Returns the ActionForm bean associated with
this request of null if none exists. | public static String | getActionFormName(HttpServletRequest request, HttpSession session) Returns the ActionForm name associated with
this request of null if none exists. | public static String | getActionMappingName(String action) Return the form action converted into an action mapping path. | public static String | getActionMappingURL(ServletContext application, HttpServletRequest request, String action) Returns the form action converted into a server-relative URI
reference. | public static ActionMessages | getErrors(HttpServletRequest request) Returns the Struts errors for this request or null
if none exist. | public static String | getForwardURL(HttpServletRequest request, ServletContext app, String forward) Returns the action forward name converted into a server-relative URI
reference. | public static Locale | getLocale(HttpServletRequest request, HttpSession session) Returns the java.util.Locale for the user. | public static MessageResources | getMessageResources(HttpServletRequest request, ServletContext app) Returns the message resources for this application or null
if not found. | public static MessageResources | getMessageResources(HttpServletRequest request, ServletContext app, String bundle) Returns the message resources with the specified bundle name for this application
or null if not found.
Parameters: app - the servlet context Parameters: bundle - The bundle name to look for. | public static ActionMessages | getMessages(HttpServletRequest request) Returns the Struts messages for this request or null
if none exist. | public static String | getToken(HttpSession session) Returns the transaction token stored in this session or
null if not used. | public static ModuleConfig | selectModule(String urlPath, ServletContext app) Select the module to which the specified request belongs, and
add return the corresponding ModuleConfig. |
errorMarkup | public static String errorMarkup(String property, HttpServletRequest request, HttpSession session, ServletContext application)(Code) | | Returns a formatted error message. The error message is assembled from
the following three pieces: First, value of message resource
"errors.header" is prepended. Then, the list of error messages is
rendered. Finally, the value of message resource "errors.footer"
is appended.
Parameters: property - the category of errors to markup and return Parameters: request - the servlet request Parameters: session - the HTTP session Parameters: application - the servlet context The formatted error message. If no error messages are queued,an empty string is returned. |
errorMarkup | public static String errorMarkup(String property, String bundle, HttpServletRequest request, HttpSession session, ServletContext application)(Code) | | Returns a formatted error message. The error message is assembled from
the following three pieces: First, value of message resource
"errors.header" is prepended. Then, the list of error messages is
rendered. Finally, the value of message resource "errors.footer"
is appended.
Parameters: property - the category of errors to markup and return Parameters: bundle - the message resource bundle to use Parameters: request - the servlet request Parameters: session - the HTTP session Parameters: application - the servlet context since: VelocityTools 1.1 The formatted error message. If no error messages are queued,an empty string is returned. |
getActionForm | public static ActionForm getActionForm(HttpServletRequest request, HttpSession session)(Code) | | Returns the ActionForm bean associated with
this request of null if none exists.
Parameters: request - the servlet request Parameters: session - the HTTP session |
getActionFormName | public static String getActionFormName(HttpServletRequest request, HttpSession session)(Code) | | Returns the ActionForm name associated with
this request of null if none exists.
Parameters: request - the servlet request Parameters: session - the HTTP session |
getActionMappingName | public static String getActionMappingName(String action)(Code) | | Return the form action converted into an action mapping path. The
value of the action property is manipulated as follows in
computing the name of the requested mapping:
- Any filename extension is removed (on the theory that extension
mapping is being used to select the controller servlet).
- If the resulting value does not start with a slash, then a
slash is prepended.
|
getActionMappingURL | public static String getActionMappingURL(ServletContext application, HttpServletRequest request, String action)(Code) | | Returns the form action converted into a server-relative URI
reference.
Parameters: application - the servlet context Parameters: request - the servlet request Parameters: action - the name of an action as per struts-config.xml |
getErrors | public static ActionMessages getErrors(HttpServletRequest request)(Code) | | Returns the Struts errors for this request or null
if none exist. Since VelocityTools 1.2, this will also check
the session (if there is one) for errors if there are no errors
in the request.
Parameters: request - the servlet request since: VelocityTools 1.1 |
getForwardURL | public static String getForwardURL(HttpServletRequest request, ServletContext app, String forward)(Code) | | Returns the action forward name converted into a server-relative URI
reference.
Parameters: app - the servlet context Parameters: request - the servlet request Parameters: forward - the name of a forward as per struts-config.xml |
getLocale | public static Locale getLocale(HttpServletRequest request, HttpSession session)(Code) | | Returns the java.util.Locale for the user. If a
locale object is not found in the user's session, the system
default locale is returned.
Parameters: request - the servlet request Parameters: session - the HTTP session |
getMessageResources | public static MessageResources getMessageResources(HttpServletRequest request, ServletContext app)(Code) | | Returns the message resources for this application or null
if not found.
Parameters: app - the servlet context since: VelocityTools 1.1 |
getMessageResources | public static MessageResources getMessageResources(HttpServletRequest request, ServletContext app, String bundle)(Code) | | Returns the message resources with the specified bundle name for this application
or null if not found.
Parameters: app - the servlet context Parameters: bundle - The bundle name to look for. If this is null , thedefault bundle name is used. since: VelocityTools 1.1 |
getMessages | public static ActionMessages getMessages(HttpServletRequest request)(Code) | | Returns the Struts messages for this request or null
if none exist. Since VelocityTools 1.2, this will also check
the session (if there is one) for messages if there are no messages
in the request.
Parameters: request - the servlet request since: VelocityTools 1.1 |
getToken | public static String getToken(HttpSession session)(Code) | | Returns the transaction token stored in this session or
null if not used.
Parameters: session - the HTTP session |
selectModule | public static ModuleConfig selectModule(String urlPath, ServletContext app)(Code) | | Select the module to which the specified request belongs, and
add return the corresponding ModuleConfig.
Parameters: urlPath - The requested URL Parameters: app - The ServletContext for this web application The ModuleConfig for the given URL path since: VelocityTools 1.1 |
|
|