Thanks for the reply Dave. My example was a simple one, but sometime
annotations are in entity level and you dont want to write different actions
to handle different situations where you could have just done with different
methods.
Anyway, I found the solution. 

AnnotationActionValidatorManager avm = new
AnnotationActionValidatorManager();
avm.validate(this, null, "getName");

After that, you just need to call 'hasErrors()' to see the result. I'm not
sure this is the best way to invoke the annotation validation though. Let me
know if you found any better solution.

Cheers,
Joe



newton.dave wrote:
> 
> joea88 wrote:
>> I've an action class like below. I put the skipvalidation annotation
>> because
>> I don't want strut to validate all annotated fields. My problem is that I
>> still want to do the validation for 'name' field. 
>> 
>> So.. is there a way to manually invoke only certain fields' annotation
>> validation? I could check whether the 'name' field is empty or not in my
>> 'execute' action, but that would be duplicating code and you don't really
>> want to do that when you have many fields in your class.
> 
> So you want to skip validation except when you don't?
> 
> I'm not aware of any mechanism that allows partial validation. If you're 
> trying to validate certain fields under certain conditions then IMO 
> annotations aren't the best way to do it, particularly if you have a 
> bunch of different methods that require different validation logic.
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-invoke-annotation-validation-manually-tp23477091p23494612.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to