Apache Struts API Documentation: Class ActionErrors

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

## org.apache.struts.action
Class ActionErrors

    java.lang.Object
      |
      +--org.apache.struts.action.ActionErrors

All Implemented Interfaces:
  java.io.Serializable

public class ActionErrors
extends java.lang.Object
implements java.io.Serializable

A class that encapsulates the error messages being reported by the `validate()` method of an `ActionForm`. Validation errors are either global to the entire `ActionForm` bean they are associated with, or they are specific to a particular bean property (and, therefore, a particular input field on the corresponding form).

Each individual error is described by an `ActionError` object, which contains a message key (to be looked up in an appropriate message resources database), and up to four placeholder arguments used for parametric substitution in the resulting message.

IMPLEMENTATION NOTE - It is assumed that these objects are created and manipulated only within the context of a single thread. Therefore, no synchronization is required for access to internal collections.

Author:
  David Geary, Craig R. McClanahan
See Also:
  Serialized Form

Field Summary
`protected java.util.HashMap` | `errors` The accumulated set of `ActionError` objects (represented as an ArrayList) for each property, keyed by property name.
`static java.lang.String` | `GLOBAL_ERROR` The "property name" marker to use for global errors, as opposed to those related to a specific property.

Constructor Summary
`ActionErrors()`

Method Summary
`void` | `add(java.lang.String property, ActionError error)` Add an error message to the set of errors for the specified property.
`void` | `clear()` Clear all error messages recorded by this object.
`boolean` | `empty()` Return `true` if there are no error messages recorded in this collection, or `false` otherwise.
`java.util.Iterator` | `get()` Return the set of all recorded error messages, without distinction by which property the messages are associated with.
`java.util.Iterator` | `get(java.lang.String property)` Return the set of error messages related to a specific property.
`java.util.Iterator` | `properties()` Return the set of property names for which at least one error has been recorded.
`int` | `size()` Return the number of errors recorded for all properties (including global errors).
`int` | `size(java.lang.String property)` Return the number of errors associated with the specified property.

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

Field Detail

### GLOBAL_ERROR

    public static final java.lang.String GLOBAL_ERROR

  The "property name" marker to use for global errors, as opposed to those related to a specific property.

### errors

    protected java.util.HashMap errors

  The accumulated set of `ActionError` objects (represented as an ArrayList) for each property, keyed by property name.

Constructor Detail

### ActionErrors

    public ActionErrors()

Method Detail

### add

    public void add(java.lang.String property,
                    ActionError error)

  Add an error message to the set of errors for the specified property.
  Parameters:
    `property` - Property name (or ActionErrors.GLOBAL_ERROR)
    `error` - The error message to be added

### clear

    public void clear()

  Clear all error messages recorded by this object.

### empty

    public boolean empty()

  Return `true` if there are no error messages recorded in this collection, or `false` otherwise.

### get

    public java.util.Iterator get()

  Return the set of all recorded error messages, without distinction by which property the messages are associated with. If there are no error messages recorded, an empty enumeration is returned.

### get

    public java.util.Iterator get(java.lang.String property)

  Return the set of error messages related to a specific property. If there are no such errors, an empty enumeration is returned.
  Parameters:
    `property` - Property name (or ActionErrors.GLOBAL_ERROR)

### properties

    public java.util.Iterator properties()

  Return the set of property names for which at least one error has been recorded. If there are no errors, an empty Iterator is returned. If you have recorded global errors, the String value of `ActionErrors.GLOBAL_ERROR` will be one of the returned property names.

### size

    public int size()

  Return the number of errors recorded for all properties (including global errors). NOTE - it is more efficient to call `empty()` if all you care about is whether or not there are any error messages at all.

### size

    public int size(java.lang.String property)

  Return the number of errors associated with the specified property.
  Parameters:
    `property` - Property name (or ActionErrors.GLOBAL_ERROR)

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

Copyright © 2000-2001 - Apache Software Foundation