This class helps provides some useful methods for retrieving objects
from different scopes of the application.
getActionError
public static ActionError getActionError(HttpServletRequest request,
ValidatorAction va,
Field field)
Gets the ActionError
based on the ValidatorAction
message and the
Field
's arg objects.
request
- the servlet requestva
- Validator actionfield
- the validator Field
getArgs
public static String[] getArgs(String actionName,
MessageResources messages,
Locale locale,
Field field)
Gets the message arguments based on the current ValidatorAction
and Field
.
actionName
- action namemessages
- message resourceslocale
- the localefield
- the validator field
getLocale
public static Locale getLocale(HttpServletRequest request)
Get the Locale
of the current user.
request
- servlet request
getMessage
public static String getMessage(HttpServletRequest request,
String key)
Gets the Locale
sensitive value based on the key passed in.
request
- servlet requestkey
- the request key
getMessage
public static String getMessage(MessageResources messages,
Locale locale,
String key)
Gets the Locale
sensitive value based on the key passed in.
messages
- The Message resourceslocale
- The locale.key
- Key used to lookup the message
getMessage
public static String getMessage(MessageResources messages,
Locale locale,
ValidatorAction va,
Field field)
Gets the locale sensitive message based on the ValidatorAction
message and the
Field
's arg objects.
messages
- The Message resourceslocale
- The localeva
- The Validator Actionfield
- The Validator Field
getMessageResources
public static MessageResources getMessageResources(HttpServletRequest request)
Retrieve MessageResources
for the module.
request
- the servlet request
getMessageResources
public static MessageResources getMessageResources(ServletContext application)
This method can only return the resources for the default
module. Use getMessageResources(HttpServletRequest) to get the
resources for the current module.
Retrieve MessageResources
for the application module.
application
- servlet context
getValidatorResources
public static ValidatorResources getValidatorResources(ServletContext application)
In Struts 1.1 This method can only return the resources for the default
module. Use getValidatorResources(HttpServletRequest, ServletContext)
to get the resources for the current application module.
Retrieve ValidatorResources
for the module.
application
- servlet context
getValidatorResources
public static ValidatorResources getValidatorResources(ServletContext application,
HttpServletRequest request)
Retrieve ValidatorResources
for the current module.
application
- Application Contextrequest
- The ServletRequest
initValidator
public static Validator initValidator(String key,
Object bean,
ServletContext application,
HttpServletRequest request,
ActionErrors errors,
int page)
Initialize the Validator
to perform validation.
key
- The key that the validation rules are under (the form elements
name attribute).bean
- The bean validation is being performed on.application
- servlet contextrequest
- The current request object.errors
- The object any errors will be stored in.page
- This in conjunction with the page property of a
Field
can control the processing of fields. If the field's
page is less than or equal to this page value, it will be processed.