Yes it is, consider:
public class Parent {
@NotNull
private String parentString = null;
@NotNull
@Valid
private Child child = null;
/*
GETTER AND SETTER METHODS GO HERE
*/
}
public class Child {
@NotEmpty
@NotNull
private String childString = null;
@NotNull
private Parent = null;
/*
GETTER AND SETTER METHODS GO HERE
*/
}
(Not that this example would require proper getter methods and some
set values)
In this case the @Valid annotation causes the validator to Validate
the child class according to the rules of that child class. The
@NotNull validation is performed first howerver /and/ it should be
noted that the @Valid annotation will not be processed on null objects
in any case. The validators also contain logic to prevent cyclic
reprocessing, for example if you set the bidirectional Parent<->Child
relationship as is possible in the example Parent /will not/ be
processed twice and therefore neither will Child. The protection
isn't perfect but it should be enough for the needs of most people.
Let me know if you have any more questions.
On Oct 8, 9:00 am, rb <[EMAIL PROTECTED]> wrote:
> Is it possible to validate nested objects from a parent?
>
> Thanks,
> Rex
>
> On Oct 6, 8:23 pm, "chris.ruffalo" <[EMAIL PROTECTED]> wrote:
>
> > Yea, easily. I didn't mean to make it Java6 specific.
>
> > isEmpty() seems like a better metaphor, I'll take a loot at it right
> > now.
>
> > Thanks for pointing that out.
>
> > On Oct 6, 9:13 am, rb <[EMAIL PROTECTED]> wrote:
>
> > > Could this be changed to support Java 5?
>
> > > The String.isEmpty() and the AbstractValidator.unrollConstraintSet
> > > have Java 6 specific stuff.
>
> > > A lot more people will be able to use this if you take out the Java 6
> > > stuff.
>
> > > Thanks,
> > > Rex
>
> > > On Oct 2, 1:22 pm, "chris.ruffalo" <[EMAIL PROTECTED]> wrote:
>
> > > > Another release has been made
> > > > @http://code.google.com/p/google-web-toolkit/issues/detail?id=343
>
> > > > Please review and send me your comments. I'd like to target this for
> > > > the GWT Incubator so I can get some more eyes on and stuff.
>
> > > > My CLA has been electronically submitted and I'm ready to go.
>
> > > > Chris Ruffalo
>
> > > > On Sep 12, 3:09 pm, "chris.ruffalo" <[EMAIL PROTECTED]> wrote:
>
> > > > > I've been looking at
> > > > > :http://code.google.com/p/google-web-toolkit/issues/detail?id=343
>
> > > > > And I've hit a few snags:
>
> > > > > Namely:
> > > > > Hosted mode works fine but compiling tries to rebind twice (even
> > > > > though I only have
> > > > > one GWT.create()) and it can't create the printwriter because the
> > > > > class it is trying to write
> > > > > already exists. I guess I need a smarter generator. (?)
>
> > > > > How the heck can I reconcile the functionality of java regex and
> > > > > compiled regex? I
> > > > > guess I could have a javascriptPattern and javaPattern property on
> > > > > each validator... but that
> > > > > sounds like a lot of work for the user. That is unless I've missed a
> > > > > new development along the
> > > > > lines of making that easier for developers.
>
> > > > > Anyway, any input would be appreciated and I think if I can figure out
> > > > > these snags and get my
> > > > > CLA finished (I applied online last night) then I could post the code
> > > > > and people could start
> > > > > poking at it a little bit because basic field/method level validation
> > > > > is working.
>
> > > > > Chris Ruffalo- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---