You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Martin Gilday <ma...@imap.cc> on 2007/11/05 17:06:00 UTC

Annotation Validation, per method?

Can you have annotation validation per method?  I have put @Validations
on both my display and update methods (display shows the record from
input), but all of the validation seems to be run at once.  Can you
achieve this with xml or annotation validation, or am I back to
validateInput methods?

Thanks,
Martin.

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


Re: Annotation Validation, per method?

Posted by Gary Affonso <gl...@greywether.com>.
Ted Husted wrote:
> Of course, if you use one-action-method per Action-class, then all the
> annotations work just fine.

+1 on one-action-method per Action class.

My personal opinion (after nearly 5 years of heavy WebWork/s2 use) is 
that this is the best-practice and that multiple action methods per 
Action class should be a rarity.

For some reason folks new to s2 seem to get it backwards and want to 
stuff a bunch of Action methods into a single Action class.

There's a lot of downsides to that (as this post and another recent post 
both illustrate) and there are few upsides.  And the upsides you might 
think are upsides (like code sharing between Action methods) are often 
not the upsides you think they are.  If you're sharing lots of code 
between Action methods, it's my experience that code belongs in other 
classes or even in other tiers.

My first WebWork app had a small number of Actions and lots of Action 
methods.  I came to regret it.

My latest s2 apps have one-action-method per Action class.  Religiously, 
no matter how silly it might seem to write a do-nearly-nothing Action. 
I'm much, much happier this way and the app is way more self-documenting.

Just my $.02.

- Gary

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


Re: Annotation Validation, per method?

Posted by Ted Husted <hu...@apache.org>.
There's a setting that you can change, but when you do, you lose
inherited property validations.

 * https://issues.apache.org/struts/browse/WW-2191

So, it's still not an optimal situation. :(

Ideally, we should be able to have per-method validations and inherit
methods placed on properties.

Of course, if you use one-action-method per Action-class, then all the
annotations work just fine.

-Ted.

On Nov 6, 2007 6:51 AM, Martin Gilday <ma...@imap.cc> wrote:
> Thanks.  Is this not a severe limitation of the annotation version if it
> is more limited than the xml version?
>
>
>
> ----- Original message -----
> From: "Fátima Silveira" <fa...@gmail.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Mon, 5 Nov 2007 17:58:32 +0100
> Subject: Re: Annotation Validation, per method?
>
> i dont know to use anotation but with xml is
> ClassName-actionAlias_method-
> validation.xml
>
> On 11/5/07, Martin Gilday <ma...@imap.cc> wrote:
> >
> > Can you have annotation validation per method?  I have put @Validations
> > on both my display and update methods (display shows the record from
> > input), but all of the validation seems to be run at once.  Can you
> > achieve this with xml or annotation validation, or am I back to
> > validateInput methods?
> >
> > Thanks,
> > Martin.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
HTH, Ted <http://www.husted.com/ted/blog/>

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


Re: Annotation Validation, per method?

Posted by Martin Gilday <ma...@imap.cc>.
Thanks.  Is this not a severe limitation of the annotation version if it
is more limited than the xml version?


----- Original message -----
From: "Fátima Silveira" <fa...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Date: Mon, 5 Nov 2007 17:58:32 +0100
Subject: Re: Annotation Validation, per method?

i dont know to use anotation but with xml is
ClassName-actionAlias_method-
validation.xml

On 11/5/07, Martin Gilday <ma...@imap.cc> wrote:
>
> Can you have annotation validation per method?  I have put @Validations
> on both my display and update methods (display shows the record from
> input), but all of the validation seems to be run at once.  Can you
> achieve this with xml or annotation validation, or am I back to
> validateInput methods?
>
> Thanks,
> Martin.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Annotation Validation, per method?

Posted by Fátima Silveira <fa...@gmail.com>.
i dont know to use anotation but with xml is ClassName-actionAlias_method-
validation.xml

On 11/5/07, Martin Gilday <ma...@imap.cc> wrote:
>
> Can you have annotation validation per method?  I have put @Validations
> on both my display and update methods (display shows the record from
> input), but all of the validation seems to be run at once.  Can you
> achieve this with xml or annotation validation, or am I back to
> validateInput methods?
>
> Thanks,
> Martin.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>