egetchell wrote:
Hello,
Does anyone have an idea how to invoke validation annotations on nested
objects?
We’re using hierarchal objects in Struts 2.1 and the validation annotations
do not seem to be firing on the child objects.
For example I have a Customer object which has an Address object as an
attribute. Annotations on the customer object fire correctly, but the
annotations on the address object are not invoked.
We’re using the VisitorFieldValidator on the Action and the
validate.validateAnnotatedMethodOnly parameter on the interceptor stack.
Any thoughts would be appreciated.
Eric Getchell | Sr. Technologist
Distributed Logic Corporation
Yes, I believe it does support nested objects but I haven't looked at
that code in a while and don't used the annotations myself. The XML
validation certainly does.
A possible explanation is that the nested objects are actually proxies
(from cglib, guice, aop, hibernate etc) and by nature of the way proxies
are created, the don't carry the method annotations of the proxied
implementation. You'll be able to find out with a break-point in your
code to check if the nested object is a proxy. If that's the case,
there is no work-around other than to use the XML validation until such
time that the validator's annotation inspection detects proxies and
pushes through them. If would be nice if you can confirm that this is
the case for you. There is already a recent issue in JIRA for
@SkipValidation detection on proxied actions.
.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]