commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MORVAL" <>
Subject Using the Validator with a Non-Struts Application
Date Thu, 06 Jan 2000 18:47:49 GMT

I have to use dinamyc Form at runtime, I need to make a plain validation of
the form. I would like to use Validator. I know the validator rule at
runtime, reading tables in Oracle

ValidatorResources resources = new ValidatorResources();

InputStream rules =

ValidatorResourcesInitializer.initialize(resources, in);

InputStream forms =

ValidatorResourcesInitializer.initialize(resources, forms);

This snippet of code creates a new instance of a ValidatorResources class
and initializes it based on the two Validator configuration files. The
ValidatorResources object can then be used throughout your application to
validate the configured JavaBeans.
I have this example:
I DO NOT UNDERSTAND WHAT IS "CHECKOUTFORM" and If I have other way to create
validator class
and to addResource to than class?

Example 4 shows a small snippet of how you go about validating a Person bean
using the initialized ValidatorResources object.

Example 4. A snippet of how to validate your beans using the Validator

// Suppose we already had a CheckoutForm object created and populated
CheckoutForm form = new CheckoutForm();

// Create a validator with the checkoutForm
Validator validator = new Validator(resources, "checkoutForm");

// Tell the validator which bean to validate against.
validator.addResource(Validator.BEAN_KEY, form);

// Validate the checkoutForm object and store the validation results
ValidatorResults results = validator.validate();
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003

View raw message