|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.velocity.tools.struts.StrutsUtils
public class StrutsUtils
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.
Constructor Summary | |
---|---|
StrutsUtils()
|
Method Summary | |
---|---|
static java.lang.String |
errorMarkup(java.lang.String property,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session,
javax.servlet.ServletContext application)
Returns a formatted error message. |
static java.lang.String |
errorMarkup(java.lang.String property,
java.lang.String bundle,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session,
javax.servlet.ServletContext application)
Returns a formatted error message. |
static org.apache.struts.action.ActionForm |
getActionForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session)
Returns the ActionForm bean associated with
this request of null if none exists. |
static java.lang.String |
getActionFormName(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session)
Returns the ActionForm name associated with this request of null if none exists. |
static java.lang.String |
getActionMappingName(java.lang.String action)
Return the form action converted into an action mapping path. |
static java.lang.String |
getActionMappingURL(javax.servlet.ServletContext application,
javax.servlet.http.HttpServletRequest request,
java.lang.String action)
Returns the form action converted into a server-relative URI reference. |
static org.apache.struts.action.ActionMessages |
getErrors(javax.servlet.http.HttpServletRequest request)
Returns the Struts errors for this request or null
if none exist. |
static java.lang.String |
getForwardURL(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext app,
java.lang.String forward)
Returns the action forward name converted into a server-relative URI reference. |
static java.util.Locale |
getLocale(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session)
Returns the java.util.Locale for the user. |
static org.apache.struts.util.MessageResources |
getMessageResources(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext app)
Returns the message resources for this application or null
if not found. |
static org.apache.struts.util.MessageResources |
getMessageResources(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext app,
java.lang.String bundle)
Returns the message resources with the specified bundle name for this application or null if not found. |
static org.apache.struts.action.ActionMessages |
getMessages(javax.servlet.http.HttpServletRequest request)
Returns the Struts messages for this request or null
if none exist. |
static java.lang.String |
getToken(javax.servlet.http.HttpSession session)
Returns the transaction token stored in this session or null if not used. |
static org.apache.struts.config.ModuleConfig |
selectModule(java.lang.String urlPath,
javax.servlet.ServletContext app)
Select the module to which the specified request belongs, and add return the corresponding ModuleConfig. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StrutsUtils()
Method Detail |
---|
public static org.apache.struts.util.MessageResources getMessageResources(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext app)
null
if not found.
app
- the servlet contextpublic static org.apache.struts.util.MessageResources getMessageResources(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext app, java.lang.String bundle)
null
if not found.
app
- the servlet contextbundle
- The bundle name to look for. If this is null
, the
default bundle name is used.public static org.apache.struts.config.ModuleConfig selectModule(java.lang.String urlPath, javax.servlet.ServletContext app)
urlPath
- The requested URLapp
- The ServletContext for this web application
public static java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpSession session)
java.util.Locale
for the user. If a
locale object is not found in the user's session, the system
default locale is returned.
request
- the servlet requestsession
- the HTTP sessionpublic static java.lang.String getToken(javax.servlet.http.HttpSession session)
null
if not used.
session
- the HTTP sessionpublic static org.apache.struts.action.ActionMessages getErrors(javax.servlet.http.HttpServletRequest request)
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.
request
- the servlet requestpublic static org.apache.struts.action.ActionMessages getMessages(javax.servlet.http.HttpServletRequest request)
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.
request
- the servlet requestpublic static org.apache.struts.action.ActionForm getActionForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpSession session)
ActionForm
bean associated with
this request of null
if none exists.
request
- the servlet requestsession
- the HTTP sessionpublic static java.lang.String getActionFormName(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpSession session)
null
if none exists.
request
- the servlet requestsession
- the HTTP sessionpublic static java.lang.String getActionMappingName(java.lang.String action)
action
property is manipulated as follows in
computing the name of the requested mapping:
public static java.lang.String getActionMappingURL(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, java.lang.String action)
application
- the servlet contextrequest
- the servlet requestaction
- the name of an action as per struts-config.xmlpublic static java.lang.String getForwardURL(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext app, java.lang.String forward)
app
- the servlet contextrequest
- the servlet requestforward
- the name of a forward as per struts-config.xmlpublic static java.lang.String errorMarkup(java.lang.String property, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpSession session, javax.servlet.ServletContext application)
property
- the category of errors to markup and returnrequest
- the servlet requestsession
- the HTTP sessionapplication
- the servlet context
public static java.lang.String errorMarkup(java.lang.String property, java.lang.String bundle, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpSession session, javax.servlet.ServletContext application)
property
- the category of errors to markup and returnbundle
- the message resource bundle to userequest
- the servlet requestsession
- the HTTP sessionapplication
- the servlet context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |