org.apache.struts.util

Class StrutsValidatorUtil


public class StrutsValidatorUtil
extends java.lang.Object

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

Version:
$Revision: 1.10 $ $Date: 2003/02/25 04:58:30 $

Authors:
David Winterfeldt
Eddie Bush

Since:
Struts 1.1

Field Summary

static String
ACTION_ERRORS_KEY
Resources key the ActionErrors is stored under.
static String
HTTP_SERVLET_REQUEST_KEY
Resources key the HttpServletRequest is stored under.
static String
SERVLET_CONTEXT_KEY
Resources key the ServletContext is stored under.

Method Summary

static ActionError
getActionError(HttpServletRequest request, ValidatorAction va, Field field)
Deprecated. As of Struts 1.1, replaced by Resources.getActionError(HttpServletRequest,ValidatorAction,Field)
static String[]
getArgs(String actionName, MessageResources messages, Locale locale, Field field)
Deprecated. As of Struts 1.1, replaced by Resources.getArgs(String,MessageResources,Locale,Field)
static Locale
getLocale(HttpServletRequest request)
Get the Locale of the current user.
static String
getMessage(HttpServletRequest request, String key)
Gets the Locale sensitive value based on the key passed in.
static String
getMessage(MessageResources messages, Locale locale, String key)
Gets the Locale sensitive value based on the key passed in.
static String
getMessage(MessageResources messages, Locale locale, ValidatorAction va, Field field)
Deprecated. As of Struts 1.1, replaced by Resources.getMessage(MessageResources,Locale,ValidatorAction,Field)
static MessageResources
getMessageResources(HttpServletRequest request)
Retrieve MessageResources for the application module.
static MessageResources
getMessageResources(ServletContext application)
Deprecated. This method can only return the resources for the default module.
static ValidatorResources
getValidatorResources(ServletContext application)
Deprecated. In Struts 1.1 This method can only return the resources for the default module.
static ValidatorResources
getValidatorResources(ServletContext application, HttpServletRequest request)
Retrieve ValidatorResources for the current module.
static Validator
initValidator(String key, Object bean, ServletContext application, HttpServletRequest request, ActionErrors errors, int page)
Deprecated. As of Struts 1.1, replaced by Resources.initValidator(String,Object,ServletContext,HttpServletRequest,ActionErrors,int)

Field Details

ACTION_ERRORS_KEY

public static String ACTION_ERRORS_KEY
Resources key the ActionErrors is stored under.


HTTP_SERVLET_REQUEST_KEY

public static String HTTP_SERVLET_REQUEST_KEY
Resources key the HttpServletRequest is stored under.


SERVLET_CONTEXT_KEY

public static String SERVLET_CONTEXT_KEY
Resources key the ServletContext is stored under.

Method Details

getActionError

public static ActionError getActionError(HttpServletRequest request,
                                         ValidatorAction va,
                                         Field field)

Deprecated. As of Struts 1.1, replaced by Resources.getActionError(HttpServletRequest,ValidatorAction,Field)

Gets the ActionError based on the ValidatorAction message and the Field's arg objects.


getArgs

public static String[] getArgs(String actionName,
                               MessageResources messages,
                               Locale locale,
                               Field field)

Deprecated. As of Struts 1.1, replaced by Resources.getArgs(String,MessageResources,Locale,Field)

Gets the message arguments based on the current ValidatorAction and Field.


getLocale

public static Locale getLocale(HttpServletRequest request)
Get the Locale of the current user.


getMessage

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


getMessage

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


getMessage

public static String getMessage(MessageResources messages,
                                Locale locale,
                                ValidatorAction va,
                                Field field)

Deprecated. As of Struts 1.1, replaced by Resources.getMessage(MessageResources,Locale,ValidatorAction,Field)

Gets the locale sensitive message based on the ValidatorAction message and the Field's arg objects.


getMessageResources

public static MessageResources getMessageResources(HttpServletRequest request)
Retrieve MessageResources for the application module.


getMessageResources

public static MessageResources getMessageResources(ServletContext application)

Deprecated. This method can only return the resources for the default module. Use getMessageResources(HttpServletRequest) to get the resources for the current application module.

Retrieve MessageResources for the application module.


getValidatorResources

public static ValidatorResources getValidatorResources(ServletContext application)

Deprecated. 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.


getValidatorResources

public static ValidatorResources getValidatorResources(ServletContext application,
                                                       HttpServletRequest request)
Retrieve ValidatorResources for the current module.


initValidator

public static Validator initValidator(String key,
                                      Object bean,
                                      ServletContext application,
                                      HttpServletRequest request,
                                      ActionErrors errors,
                                      int page)

Deprecated. As of Struts 1.1, replaced by Resources.initValidator(String,Object,ServletContext,HttpServletRequest,ActionErrors,int)

Initialize the Validator to perform validation.

Parameters:
key - The key that the validation rules are under (the form elements name attribute).
request - The current request object.
errors - The object any errors will be stored in.


Copyright B) 2000-2005 - Apache Software Foundation