struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <>
Subject Re: Validation Complications - Validating only those fields displayed in the form, and not the rest of the object in use
Date Wed, 09 Jan 2008 23:51:13 GMT
Singulariter wrote:
> Hi all,
> Quick Struts 2 validation question:
> Is it possible to validate only the fields displayed in a form, when the
> form's fields are part of a larger object that uses annotation validation?
> The problem is that I am using one object across many forms, each form
> contains some of the values for that object. When each form validates it
> validates everything in that object with a validation annotation, even if it
> is not contained in the current form.
> It seems as though there should be a Validate only form contents option, am
> I missing something?

This sounds like an impedance match between the validation rules you've 
set up on the object in question, and how you're actually using it. If 
you annotate the object with validation rules, all of them apply any 
time the object is validated. You're effectively saying that the object 
is only valid if those validation rules are all met.

If you need to use different validation rules in different uses of the 
object, you'll need to pull the validation rules out of the object 
itself and associate them with just the actions they apply for.

AFAIK, there is no way to toggle the application of individual 
validation annotations on an object on and off. If you only want to 
validate the contents of the form, tie the validation rules to the form 



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message