Package org.apache.struts.validator
Class Resources
java.lang.Object
org.apache.struts.validator.Resources
This class helps provides some useful methods for retrieving objects from
different scopes of the application.
- Since:
- Struts 1.1
- Version:
- $Rev$ $Date: 2005-09-16 23:34:41 -0400 (Fri, 16 Sep 2005) $
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ActionMessage
getActionMessage
(HttpServletRequest request, ValidatorAction va, Field field) Deprecated.Use getActionMessage(Validator, HttpServletRequest, ValidatorAction, Field) method insteadstatic ActionMessage
getActionMessage
(Validator validator, HttpServletRequest request, ValidatorAction va, Field field) Gets theActionMessage
based on theValidatorAction
message and theField
's arg objects.static String[]
getArgs
(String actionName, MessageResources messages, Locale locale, Field field) Gets the message arguments based on the currentValidatorAction
andField
.static String
getMessage
(HttpServletRequest request, String key) Gets theLocale
sensitive value based on the key passed in.static String
getMessage
(ServletContext application, HttpServletRequest request, MessageResources defaultMessages, Locale locale, ValidatorAction va, Field field) Gets theLocale
sensitive value based on the key passed in.static String
getMessage
(MessageResources messages, Locale locale, String key) Gets theLocale
sensitive value based on the key passed in.static String
getMessage
(MessageResources messages, Locale locale, ValidatorAction va, Field field) Gets the locale sensitive message based on theValidatorAction
message and theField
's arg objects.static MessageResources
getMessageResources
(HttpServletRequest request) RetrieveMessageResources
for the module.static MessageResources
getMessageResources
(ServletContext application, HttpServletRequest request, String bundle) RetrieveMessageResources
for the module and bundle.static ValidatorResources
getValidatorResources
(ServletContext application, HttpServletRequest request) RetrieveValidatorResources
for the current module.static String
getVarValue
(String varName, Field field, Validator validator, HttpServletRequest request, boolean required) Get the value of a variable.static String
getVarValue
(Var var, ServletContext application, HttpServletRequest request, boolean required) Get the value of a variable.static Validator
initValidator
(String key, Object bean, ServletContext application, HttpServletRequest request, ActionMessages errors, int page) Initialize theValidator
to perform validation.
-
Constructor Details
-
Resources
public Resources()
-
-
Method Details
-
getValidatorResources
public static ValidatorResources getValidatorResources(ServletContext application, HttpServletRequest request) RetrieveValidatorResources
for the current module.- Parameters:
application
- Application Contextrequest
- The ServletRequest
-
getMessageResources
RetrieveMessageResources
for the module.- Parameters:
request
- the servlet request
-
getMessageResources
public static MessageResources getMessageResources(ServletContext application, HttpServletRequest request, String bundle) RetrieveMessageResources
for the module and bundle.- Parameters:
application
- the servlet contextrequest
- the servlet requestbundle
- the bundle key
-
getVarValue
public static String getVarValue(String varName, Field field, Validator validator, HttpServletRequest request, boolean required) Get the value of a variable.- Parameters:
varName
- The variable namefield
- the validator Fieldvalidator
- The Validatorrequest
- the servlet requestrequired
- Whether the variable is mandatory- Returns:
- The variable's value
-
getVarValue
public static String getVarValue(Var var, ServletContext application, HttpServletRequest request, boolean required) Get the value of a variable.- Parameters:
var
- the validator variableapplication
- The ServletContextrequest
- the servlet requestrequired
- Whether the variable is mandatory- Returns:
- The variables values
-
getMessage
Gets theLocale
sensitive value based on the key passed in.- Parameters:
messages
- The Message resourceslocale
- The locale.key
- Key used to lookup the message
-
getMessage
Gets theLocale
sensitive value based on the key passed in.- Parameters:
request
- servlet requestkey
- the request key
-
getMessage
public static String getMessage(MessageResources messages, Locale locale, ValidatorAction va, Field field) Gets the locale sensitive message based on theValidatorAction
message and theField
's arg objects.- Parameters:
messages
- The Message resourceslocale
- The localeva
- The Validator Actionfield
- The Validator Field
-
getMessage
public static String getMessage(ServletContext application, HttpServletRequest request, MessageResources defaultMessages, Locale locale, ValidatorAction va, Field field) Gets theLocale
sensitive value based on the key passed in.- Parameters:
application
- the servlet contextrequest
- the servlet requestdefaultMessages
- The default Message resourceslocale
- The localeva
- The Validator Actionfield
- The Validator Field
-
getActionMessage
@Deprecated public static ActionMessage getActionMessage(HttpServletRequest request, ValidatorAction va, Field field) Deprecated.Use getActionMessage(Validator, HttpServletRequest, ValidatorAction, Field) method insteadGets theActionMessage
based on theValidatorAction
message and theField
's arg objects.Note: this method does not respect bundle information stored with the field's <msg> or <arg> elements, and localization will not work for alternative resource bundles. This method is deprecated for this reason, and you should use
getActionMessage(Validator,HttpServletRequest,ValidatorAction,Field)
instead.- Parameters:
request
- the servlet requestva
- Validator actionfield
- the validator Field
-
getActionMessage
public static ActionMessage getActionMessage(Validator validator, HttpServletRequest request, ValidatorAction va, Field field) Gets theActionMessage
based on theValidatorAction
message and theField
's arg objects.- Parameters:
validator
- the Validatorrequest
- 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 currentValidatorAction
andField
.- Parameters:
actionName
- action namemessages
- message resourceslocale
- the localefield
- the validator field
-
initValidator
public static Validator initValidator(String key, Object bean, ServletContext application, HttpServletRequest request, ActionMessages errors, int page) Initialize theValidator
to perform validation.- Parameters:
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 aField
can control the processing of fields. If the field's page is less than or equal to this page value, it will be processed.
-