You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by David Rupp <da...@ruppconsulting.com> on 2007/01/30 04:43:43 UTC

per-method validations for annotations

Hi, all.

I've submitted a patch to the XWork project (issue XW-470) that  
enables per-method validations when using annotations. This is, IMO,  
an improvement over the current behavior, with which all validations  
are attached to the class, and *all* fire when *any* method is  
executed. Since validation annotations, by definition, *must* be  
defined on a specific method, it seems more reasonable to expect that  
the validations defined on a given method would fire when - and only  
when - that method is executed.

I have a specific need for this behavior on my current project, but  
I'd rather not be in the position of maintaining a forked version of  
XWork just for it. I'd love it if some of the folks from this group  
could take a look at my patch (included on the issue) and let me know  
how it can be improved, assuming I'm not the only one who would like  
to see this behavior implemented.

Regards,
David

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


Re: per-method validations for annotations

Posted by Ted Husted <hu...@apache.org>.
I'm not arguing against annotations, only saying that per-method
valdidations are supported.

One workaround would be to let the validation.xml include another
validation.xml. I haven't tried, but this might already be possible
using XML entities.

But, again, the annotation support would also be a good thing.

-Ted.

On 1/31/07, David H. DeWolf <dd...@apache.org> wrote:
> Yes, but that requires seperate validations config per method - even if
> they are identical.
>
> Take a dumb example. . .suppose you have an action with simple methods:
>
> load
> create
> update
> delete
>
> Perhaps you have the same validation on create and update, but do not
> want them to execute on load and delete.
>
> If I want per-method validation, I would have to create two distinct
> validation.xml files (CrudAction-create-validation.xml &
> CrudAction-update-validation.xml) as opposed to only one which is
> "activated" for the specific action methods I want validation to occur on.
>
> Are there any ways around the duplication problem that I'm not aware of?
>
> David
>
> Ted Husted wrote:
> > Per-method validations are supported, using the convention
> >
> > * ActionClass-actionMethod-validation.xml
> >
> > This approach doesn't work with "dynamic method invocation" though
> > (the WW ! notation), because of the way DMI is implemented. Per method
> > validation does work with wildcards, though.
> >
> > -Ted.
> >
> > On 1/29/07, David Rupp <da...@ruppconsulting.com> wrote:
> >> Hi, all.
> >>
> >> I've submitted a patch to the XWork project (issue XW-470) that
> >> enables per-method validations when using annotations. This is, IMO,
> >> an improvement over the current behavior, with which all validations
> >> are attached to the class, and *all* fire when *any* method is
> >> executed. Since validation annotations, by definition, *must* be
> >> defined on a specific method, it seems more reasonable to expect that
> >> the validations defined on a given method would fire when - and only
> >> when - that method is executed.
> >>
> >> I have a specific need for this behavior on my current project, but
> >> I'd rather not be in the position of maintaining a forked version of
> >> XWork just for it. I'd love it if some of the folks from this group
> >> could take a look at my patch (included on the issue) and let me know
> >> how it can be improved, assuming I'm not the only one who would like
> >> to see this behavior implemented.
> >>
> >> Regards,
> >> David
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


-- 
HTH, Ted.
* http://www.husted.com/struts/

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


Re: per-method validations for annotations

Posted by "David H. DeWolf" <dd...@apache.org>.
Yes, but that requires seperate validations config per method - even if 
they are identical.

Take a dumb example. . .suppose you have an action with simple methods:

load
create
update
delete

Perhaps you have the same validation on create and update, but do not 
want them to execute on load and delete.

If I want per-method validation, I would have to create two distinct 
validation.xml files (CrudAction-create-validation.xml & 
CrudAction-update-validation.xml) as opposed to only one which is 
"activated" for the specific action methods I want validation to occur on.

Are there any ways around the duplication problem that I'm not aware of?

David

Ted Husted wrote:
> Per-method validations are supported, using the convention
> 
> * ActionClass-actionMethod-validation.xml
> 
> This approach doesn't work with "dynamic method invocation" though
> (the WW ! notation), because of the way DMI is implemented. Per method
> validation does work with wildcards, though.
> 
> -Ted.
> 
> On 1/29/07, David Rupp <da...@ruppconsulting.com> wrote:
>> Hi, all.
>>
>> I've submitted a patch to the XWork project (issue XW-470) that
>> enables per-method validations when using annotations. This is, IMO,
>> an improvement over the current behavior, with which all validations
>> are attached to the class, and *all* fire when *any* method is
>> executed. Since validation annotations, by definition, *must* be
>> defined on a specific method, it seems more reasonable to expect that
>> the validations defined on a given method would fire when - and only
>> when - that method is executed.
>>
>> I have a specific need for this behavior on my current project, but
>> I'd rather not be in the position of maintaining a forked version of
>> XWork just for it. I'd love it if some of the folks from this group
>> could take a look at my patch (included on the issue) and let me know
>> how it can be improved, assuming I'm not the only one who would like
>> to see this behavior implemented.
>>
>> Regards,
>> David
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: per-method validations for annotations

Posted by Ted Husted <hu...@apache.org>.
Per-method validations are supported, using the convention

* ActionClass-actionMethod-validation.xml

This approach doesn't work with "dynamic method invocation" though
(the WW ! notation), because of the way DMI is implemented. Per method
validation does work with wildcards, though.

-Ted.

On 1/29/07, David Rupp <da...@ruppconsulting.com> wrote:
> Hi, all.
>
> I've submitted a patch to the XWork project (issue XW-470) that
> enables per-method validations when using annotations. This is, IMO,
> an improvement over the current behavior, with which all validations
> are attached to the class, and *all* fire when *any* method is
> executed. Since validation annotations, by definition, *must* be
> defined on a specific method, it seems more reasonable to expect that
> the validations defined on a given method would fire when - and only
> when - that method is executed.
>
> I have a specific need for this behavior on my current project, but
> I'd rather not be in the position of maintaining a forked version of
> XWork just for it. I'd love it if some of the folks from this group
> could take a look at my patch (included on the issue) and let me know
> how it can be improved, assuming I'm not the only one who would like
> to see this behavior implemented.
>
> Regards,
> David

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


Re: per-method validations for annotations

Posted by André Faria <an...@mandic.com.br>.
That's would be really usefull...
I am waiting too, If I could heap in something...

Thank's,
André Faria


David H. DeWolf escreveu:
> It's something I actually will be needing in the near future.  If no 
> one beats me, I'll probably take a look at the patch (late?) next week.
>
> David
>
> Laurie Harper wrote:
>> David Rupp wrote:
>>> Hi, all.
>>>
>>> I've submitted a patch to the XWork project (issue XW-470) that 
>>> enables per-method validations when using annotations. This is, IMO, 
>>> an improvement over the current behavior, with which all validations 
>>> are attached to the class, and *all* fire when *any* method is 
>>> executed. Since validation annotations, by definition, *must* be 
>>> defined on a specific method, it seems more reasonable to expect 
>>> that the validations defined on a given method would fire when - and 
>>> only when - that method is executed.
>>>
>>> I have a specific need for this behavior on my current project, but 
>>> I'd rather not be in the position of maintaining a forked version of 
>>> XWork just for it. I'd love it if some of the folks from this group 
>>> could take a look at my patch (included on the issue) and let me 
>>> know how it can be improved, assuming I'm not the only one who would 
>>> like to see this behavior implemented.
>>
>> +1, since we've already had at least one user expecting it to work 
>> like this and it would certainly make the framework more flexible. I 
>> haven't looked at the patch but I'd like to see this functionality 
>> added, in some form.
>>
>> L.


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


Re: per-method validations for annotations

Posted by "David H. DeWolf" <dd...@apache.org>.
It's something I actually will be needing in the near future.  If no one 
beats me, I'll probably take a look at the patch (late?) next week.

David

Laurie Harper wrote:
> David Rupp wrote:
>> Hi, all.
>>
>> I've submitted a patch to the XWork project (issue XW-470) that 
>> enables per-method validations when using annotations. This is, IMO, 
>> an improvement over the current behavior, with which all validations 
>> are attached to the class, and *all* fire when *any* method is 
>> executed. Since validation annotations, by definition, *must* be 
>> defined on a specific method, it seems more reasonable to expect that 
>> the validations defined on a given method would fire when - and only 
>> when - that method is executed.
>>
>> I have a specific need for this behavior on my current project, but 
>> I'd rather not be in the position of maintaining a forked version of 
>> XWork just for it. I'd love it if some of the folks from this group 
>> could take a look at my patch (included on the issue) and let me know 
>> how it can be improved, assuming I'm not the only one who would like 
>> to see this behavior implemented.
> 
> +1, since we've already had at least one user expecting it to work like 
> this and it would certainly make the framework more flexible. I haven't 
> looked at the patch but I'd like to see this functionality added, in 
> some form.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: per-method validations for annotations

Posted by Laurie Harper <la...@holoweb.net>.
David Rupp wrote:
> Hi, all.
> 
> I've submitted a patch to the XWork project (issue XW-470) that enables 
> per-method validations when using annotations. This is, IMO, an 
> improvement over the current behavior, with which all validations are 
> attached to the class, and *all* fire when *any* method is executed. 
> Since validation annotations, by definition, *must* be defined on a 
> specific method, it seems more reasonable to expect that the validations 
> defined on a given method would fire when - and only when - that method 
> is executed.
> 
> I have a specific need for this behavior on my current project, but I'd 
> rather not be in the position of maintaining a forked version of XWork 
> just for it. I'd love it if some of the folks from this group could take 
> a look at my patch (included on the issue) and let me know how it can be 
> improved, assuming I'm not the only one who would like to see this 
> behavior implemented.

+1, since we've already had at least one user expecting it to work like 
this and it would certainly make the framework more flexible. I haven't 
looked at the patch but I'd like to see this functionality added, in 
some form.

L.


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