org.apache.struts.validator
Class Resources

java.lang.Object
  extended by org.apache.struts.validator.Resources

public class Resources
extends java.lang.Object

This class helps provides some useful methods for retrieving objects from different scopes of the application.

Since:
Struts 1.1
Version:
$Rev: 476419 $ $Date: 2005-09-16 23:34:41 -0400 (Fri, 16 Sep 2005) $

Constructor Summary
Resources()
           
 
Method Summary
static ActionMessage getActionMessage(javax.servlet.http.HttpServletRequest request, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field)
          Deprecated. Use getActionMessage(Validator, HttpServletRequest, ValidatorAction, Field) method instead
static ActionMessage getActionMessage(org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field)
          Gets the ActionMessage based on the ValidatorAction message and the Field's arg objects.
static java.lang.String[] getArgs(java.lang.String actionName, MessageResources messages, java.util.Locale locale, org.apache.commons.validator.Field field)
          Gets the message arguments based on the current ValidatorAction and Field.
static java.lang.String getMessage(javax.servlet.http.HttpServletRequest request, java.lang.String key)
          Gets the Locale sensitive value based on the key passed in.
static java.lang.String getMessage(MessageResources messages, java.util.Locale locale, java.lang.String key)
          Gets the Locale sensitive value based on the key passed in.
static java.lang.String getMessage(MessageResources messages, java.util.Locale locale, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field)
          Gets the locale sensitive message based on the ValidatorAction message and the Field's arg objects.
static java.lang.String getMessage(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, MessageResources defaultMessages, java.util.Locale locale, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field)
          Gets the Locale sensitive value based on the key passed in.
static MessageResources getMessageResources(javax.servlet.http.HttpServletRequest request)
          Retrieve MessageResources for the module.
static MessageResources getMessageResources(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, java.lang.String bundle)
          Retrieve MessageResources for the module and bundle.
static org.apache.commons.validator.ValidatorResources getValidatorResources(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request)
          Retrieve ValidatorResources for the current module.
static java.lang.String getVarValue(java.lang.String varName, org.apache.commons.validator.Field field, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request, boolean required)
          Get the value of a variable.
static java.lang.String getVarValue(org.apache.commons.validator.Var var, javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, boolean required)
          Get the value of a variable.
static org.apache.commons.validator.Validator initValidator(java.lang.String key, java.lang.Object bean, javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, ActionMessages errors, int page)
          Initialize the Validator to perform validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Resources

public Resources()
Method Detail

getValidatorResources

public static org.apache.commons.validator.ValidatorResources getValidatorResources(javax.servlet.ServletContext application,
                                                                                    javax.servlet.http.HttpServletRequest request)
Retrieve ValidatorResources for the current module.

Parameters:
application - Application Context
request - The ServletRequest

getMessageResources

public static MessageResources getMessageResources(javax.servlet.http.HttpServletRequest request)
Retrieve MessageResources for the module.

Parameters:
request - the servlet request

getMessageResources

public static MessageResources getMessageResources(javax.servlet.ServletContext application,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   java.lang.String bundle)
Retrieve MessageResources for the module and bundle.

Parameters:
application - the servlet context
request - the servlet request
bundle - the bundle key

getVarValue

public static java.lang.String getVarValue(java.lang.String varName,
                                           org.apache.commons.validator.Field field,
                                           org.apache.commons.validator.Validator validator,
                                           javax.servlet.http.HttpServletRequest request,
                                           boolean required)
Get the value of a variable.

Parameters:
varName - The variable name
field - the validator Field
validator - The Validator
request - the servlet request
required - Whether the variable is mandatory
Returns:
The variable's value

getVarValue

public static java.lang.String getVarValue(org.apache.commons.validator.Var var,
                                           javax.servlet.ServletContext application,
                                           javax.servlet.http.HttpServletRequest request,
                                           boolean required)
Get the value of a variable.

Parameters:
var - the validator variable
application - The ServletContext
request - the servlet request
required - Whether the variable is mandatory
Returns:
The variables values

getMessage

public static java.lang.String getMessage(MessageResources messages,
                                          java.util.Locale locale,
                                          java.lang.String key)
Gets the Locale sensitive value based on the key passed in.

Parameters:
messages - The Message resources
locale - The locale.
key - Key used to lookup the message

getMessage

public static java.lang.String getMessage(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String key)
Gets the Locale sensitive value based on the key passed in.

Parameters:
request - servlet request
key - the request key

getMessage

public static java.lang.String getMessage(MessageResources messages,
                                          java.util.Locale locale,
                                          org.apache.commons.validator.ValidatorAction va,
                                          org.apache.commons.validator.Field field)
Gets the locale sensitive message based on the ValidatorAction message and the Field's arg objects.

Parameters:
messages - The Message resources
locale - The locale
va - The Validator Action
field - The Validator Field

getMessage

public static java.lang.String getMessage(javax.servlet.ServletContext application,
                                          javax.servlet.http.HttpServletRequest request,
                                          MessageResources defaultMessages,
                                          java.util.Locale locale,
                                          org.apache.commons.validator.ValidatorAction va,
                                          org.apache.commons.validator.Field field)
Gets the Locale sensitive value based on the key passed in.

Parameters:
application - the servlet context
request - the servlet request
defaultMessages - The default Message resources
locale - The locale
va - The Validator Action
field - The Validator Field

getActionMessage

public static ActionMessage getActionMessage(javax.servlet.http.HttpServletRequest request,
                                             org.apache.commons.validator.ValidatorAction va,
                                             org.apache.commons.validator.Field field)
Deprecated. Use getActionMessage(Validator, HttpServletRequest, ValidatorAction, Field) method instead

Gets the ActionMessage based on the ValidatorAction message and the Field'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 request
va - Validator action
field - the validator Field

getActionMessage

public static ActionMessage getActionMessage(org.apache.commons.validator.Validator validator,
                                             javax.servlet.http.HttpServletRequest request,
                                             org.apache.commons.validator.ValidatorAction va,
                                             org.apache.commons.validator.Field field)
Gets the ActionMessage based on the ValidatorAction message and the Field's arg objects.

Parameters:
validator - the Validator
request - the servlet request
va - Validator action
field - the validator Field

getArgs

public static java.lang.String[] getArgs(java.lang.String actionName,
                                         MessageResources messages,
                                         java.util.Locale locale,
                                         org.apache.commons.validator.Field field)
Gets the message arguments based on the current ValidatorAction and Field.

Parameters:
actionName - action name
messages - message resources
locale - the locale
field - the validator field

initValidator

public static org.apache.commons.validator.Validator initValidator(java.lang.String key,
                                                                   java.lang.Object bean,
                                                                   javax.servlet.ServletContext application,
                                                                   javax.servlet.http.HttpServletRequest request,
                                                                   ActionMessages errors,
                                                                   int page)
Initialize the Validator 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 context
request - 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.


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.