Using Bundled Exceptions

You can bundle exceptions until validation is called by using this method on the Transaction interface:

setBundledExceptionMode(true);

When your application is setting attributes, all exceptions are cached and thrown when the entity or view row is validated, or when an exception is explicitly thrown while validating. All attributes are not set if an exception is thrown, and all attributes that threw exceptions retain their old values.

You can also register exceptions instead of throwing them. These exceptions are thrown at the end of validation or when an exception is thrown explicitly:

void registerRowException(JboException e)
void clearRowExceptions()

When validating a row, you can check if an attribute is valid by using:

boolean hasAttributeException(String name)
boolean hasAttributeException(int index)

You have access to the cached exceptions through:

boolean hasDeferredExceptions()
ArrayList getAllExceptions()
void clearallExceptions()

JboException has a method that converts entity object exceptions to a view object exception:

public void doEntityToVOMapping(ApplicationModule rootAm, ViewObject[] vos)

The object name and attribute name retrieved from the exception returns a view object usage name and a view attribute name, respectively. Attribute validation exceptions thrown from ViewRows must set the exception NeedsEntityToVOMapping flag to false.

There are four kinds of validation exceptions and they all extend from ValidationException:

These exceptions can be thrown from entity object rows or view object rows.

To instantiate attribute validation exceptions, you must pass

To instantiate a row validation exception, you must pass the full entity object definition name for entity object rows, or view usage name for view rows.

See the Javadoc for more information on the methods discussed in this topic.