Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts.validator
Class BeanValidatorForm

    java.lang.Object
      org.apache.struts.action.ActionForm
          org.apache.struts.validator.ValidatorForm
              org.apache.struts.validator.BeanValidatorForm

All Implemented Interfaces:
  Serializable, DynaBean

Direct Known Subclasses:
  LazyValidatorForm

    public class BeanValidatorForm

extends ValidatorForm
implements DynaBean, Serializable

Struts validator `ActionForm` backed by either a `DynaBean` or POJO JavaBean.

Passing a POJO JavaBean to the constructor will automatically create an associated `WrapDynaBean`. One use for this would be to migrate view objects from an existing system which, for the usual reasons, can't be changed to extend .

This form is based on the standard struts `ValidatorForm` for use with the Validator framework and validates either using the name from the Struts `ActionMapping` or the `ActionMapping`'s path depending on whether `pathValidation` is `true` or `false`.

Note: WrapDynaBean is NOT serializable. If you use this class with a WrapDynaBean (as described above), you should not store your form in session scope.

See Also:
  Serialized Form

Field Summary
`protected DynaBean` | `dynaBean` The `DynaBean` that this ActionForm is backed by.
`protected static Log` | `logger` Commons Logging
`protected boolean` | `pathValidation` Indicates whether the ActionMapping's path should be used for the validation key.

Fields inherited from class org.apache.struts.validator.ValidatorForm
`page, validatorResults`

Fields inherited from class org.apache.struts.action.ActionForm
`multipartRequestHandler, servlet`

Constructor Summary
`BeanValidatorForm(Object bean)` Construct a new `BeanValidatorForm` with the specified bean.

Method Summary
`boolean` | `contains(String name, String key)` Does the specified mapped property contain a value for the specified key value?
`Object` | `get(String name)` Return the value of a simple property with the specified name.
`Object` | `get(String name, int index)` Return the value of an indexed property with the specified name.
`Object` | `get(String name, String key)` Return the value of a mapped property with the specified name, or `null` if there is no value for the specified key.
`DynaBean` | `getDynaBean()` Return the `DynaBean` that this `ActionForm` is backed by.
`DynaClass` | `getDynaClass()` Return the `DynaClass` instance that describes the set of properties available for this DynaBean.
`Object` | `getInstance()` Return the `Bean` that this `ActionForm` is backed by.
`String` | `getStrutsConfigFormName()` Return name used to identify the ActionForm in the struts-config.xml.
`String` | `getValidationKey(ActionMapping mapping, HttpServletRequest request)` Returns the Validation key
`void` | `initialize(FormBeanConfig formBeanConfig)` Perform intialization of the ActionForm.
`protected boolean` | `isPathValidation()` Indicates whether this form should validate based on the `ActionMapping`'s path.
`void` | `remove(String name, String key)` Remove any existing value for the specified key on the specified mapped property.
`void` | `set(String name, int index, Object value)` Set the value of an indexed property with the specified name.
`void` | `set(String name, Object value)` Set the value of a simple property with the specified name.
`void` | `set(String name, String key, Object value)` Set the value of a mapped property with the specified name.
`protected void` | `setPathValidation(boolean pathValidation)` Set whether this form should validate based on the `ActionMapping`'s path.
`int` | `size(String name)` Return the size of an indexed or mapped property.

Methods inherited from class org.apache.struts.validator.ValidatorForm
`getPage, getResultValueMap, getValidatorResults, reset, setPage, setValidatorResults, validate`

Methods inherited from class org.apache.struts.action.ActionForm
`getMultipartRequestHandler, getServlet, getServletWrapper, reset, setMultipartRequestHandler, setServlet, validate`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected static Log logger

  Commons Logging

### dynaBean

    protected DynaBean dynaBean

  The `DynaBean` that this ActionForm is backed by.

### pathValidation

    protected boolean pathValidation

  Indicates whether the ActionMapping's path should be used for the validation key.

Constructor Detail

### BeanValidatorForm

    public BeanValidatorForm(Object bean)

  Construct a new `BeanValidatorForm` with the specified bean.

Method Detail

### setPathValidation

    protected void setPathValidation(boolean pathValidation)

  Set whether this form should validate based on the `ActionMapping`'s path.

### isPathValidation

    protected boolean isPathValidation()

  Indicates whether this form should validate based on the `ActionMapping`'s path.

### initialize

    public void initialize(FormBeanConfig formBeanConfig)

  Perform intialization of the ActionForm.

  This method is called when the form is created.

  Since:
    Struts 1.3.6

### getStrutsConfigFormName

    public String getStrutsConfigFormName()

  Return name used to identify the ActionForm in the struts-config.xml.

  Since:
    Struts 1.3.6

### getDynaBean

    public DynaBean getDynaBean()

  Return the `DynaBean` that this `ActionForm` is backed by.

### getInstance

    public Object getInstance()

  Return the `Bean` that this `ActionForm` is backed by.

  If the `DynaBean` is a `WrapDynaBean` type then this method returns the 'Wrapped' POJO bean associated with it. If you require the actual `WrapDynaBean` then use the `getDynaBean()` method.

### size

    public int size(String name)

  Return the size of an indexed or mapped property.

### getValidationKey

    public String getValidationKey(ActionMapping mapping,
                                   HttpServletRequest request)

  Returns the Validation key

  Overrides:
    `getValidationKey` in class `ValidatorForm`
  Parameters:
    `mapping` - The mapping used to select this instance
    `request` - The servlet request we are processing
  Returns:
    validation key to use

### getDynaClass

    public DynaClass getDynaClass()

  Return the `DynaClass` instance that describes the set of properties available for this DynaBean.

  Specified by:
    `getDynaClass` in interface `DynaBean`

### get

    public Object get(String name)

  Return the value of a simple property with the specified name.

  Specified by:
    `get` in interface `DynaBean`
  Parameters:
    `name` - Name of the property whose value is to be retrieved

### get

    public Object get(String name,
                      int index)

  Return the value of an indexed property with the specified name.

  Specified by:
    `get` in interface `DynaBean`
  Parameters:
    `name` - Name of the property whose value is to be retrieved
    `index` - Index of the value to be retrieved

### get

    public Object get(String name,
                      String key)

  Return the value of a mapped property with the specified name, or `null` if there is no value for the specified key.

  Specified by:
    `get` in interface `DynaBean`
  Parameters:
    `name` - Name of the property whose value is to be retrieved
    `key` - Key of the value to be retrieved

### set

    public void set(String name,
                    Object value)

  Set the value of a simple property with the specified name.

  Specified by:
    `set` in interface `DynaBean`
  Parameters:
    `name` - Name of the property whose value is to be set
    `value` - Value to which this property is to be set

### set

    public void set(String name,
                    int index,
                    Object value)

  Set the value of an indexed property with the specified name.

  Specified by:
    `set` in interface `DynaBean`
  Parameters:
    `name` - Name of the property whose value is to be set
    `index` - Index of the property to be set
    `value` - Value to which this property is to be set

### set

    public void set(String name,
                    String key,
                    Object value)

  Set the value of a mapped property with the specified name.

  Specified by:
    `set` in interface `DynaBean`
  Parameters:
    `name` - Name of the property whose value is to be set
    `key` - Key of the property to be set
    `value` - Value to which this property is to be set

### contains

    public boolean contains(String name,
                            String key)

  Does the specified mapped property contain a value for the specified key value?

  Specified by:
    `contains` in interface `DynaBean`
  Parameters:
    `name` - Name of the property to check
    `key` - Name of the key to check

### remove

    public void remove(String name,
                       String key)

  Remove any existing value for the specified key on the specified mapped property.

  Specified by:
    `remove` in interface `DynaBean`
  Parameters:
    `name` - Name of the property for which a value is to be removed
    `key` - Key of the value to be removed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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