I've implemented a subclass on the DefaultValidationMetadataProvider
that does exactly what you suggest. (One of the nice things you can do
is pick up implicit validation rules for some things from JPA
annotations.)  It's not too hard really - just look at the code that
does the "ValidateNestedProperties", and it'll be something like that.

One of the things you may end up doing, as I did, is putting together
some code to handle multiple layers of validation metadata. For
example, you may want to let the action beans handle the stipulation
of what properties are "required" - consider the difference between a
"create" and an "edit" operation. To do that, you're variant of the
metadata provider will have to perform the ValidateNestedProperties
work like the current code does, and then proceed to look down into
the property type to look for more validation information. When it
finds it, it will want to merge that onto what's been found already.

On Sun, Mar 1, 2009 at 9:37 AM, VANKEISBELCK Remi <[email protected]> wrote:
> Hi folks,
>
> I'd like to use the Stripes validation annotations in POJOs that are
> used as ActionBean properties :
>
> // not an action bean
> class MyPojo {
> �...@validate(required=true)
>  private String myProp; // + usual get/set
> }
>
> class MyActionBean implements ActionBean {
>  private MyPojo myPojo; // + get/set, but without @ValidateNestedProperties
> }
>
> Of course, I don't want to change anything in the action itself (using
> ValidateNestedProperties).
>
> The idea is simple : I'd like Stripes to recurse on the nested
> properties, and check for Validation Annotations there, not only on
> the bean itself...
>
> I'm currrently looking at how DefaultActionBeanPropertyBinder and
> DefaultValidationMetadataProvider, but it seems (after a quick look)
> that it's not possible to hook some "instance-specific" code that
> would do the job of recursing on "myProp", and add the nested object's
> class Validation Annotations to the top level's bean class... I'm
> currently trying to hack DefaultPropertyBinder, but it seems to
> require quite a lot of stuff to be overriden (and almost entirely
> rewritten)...
>
> Any idea ?
>
> Cheers
>
> Remi
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>



-- 
Turtle, turtle, on the ground,
Pink and shiny, turn around.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to