You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Singulariter <gk...@citytechinc.com> on 2008/01/09 22:41:27 UTC

Validation Complications - Validating only those fields displayed in the form, and not the rest of the object in use

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?

Thanks in advance!
George
-- 
View this message in context: http://www.nabble.com/Validation-Complications---Validating-only-those-fields-displayed-in-the-form%2C-and-not-the-rest-of-the-object-in-use-tp14722298p14722298.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation Complications - Validating only those fields displayed in the form, and not the rest of the object in use

Posted by Singulariter <gk...@citytechinc.com>.
Great!  I guess I'll be switching to XML validation or action specific
validation.

Thanks for the info :)
George



Laurie Harper wrote:
> 
> 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 
> itself.
> 
> HTH,
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Validation-Complications---Validating-only-those-fields-displayed-in-the-form%2C-and-not-the-rest-of-the-object-in-use-tp14722298p14726942.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation Complications - Validating only those fields displayed in the form, and not the rest of the object in use

Posted by Laurie Harper <la...@holoweb.net>.
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 
itself.

HTH,

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org