You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ted Husted <hu...@apache.org> on 2007/09/18 11:27:22 UTC
Re: S2 : Validation per Action method - ideas?
I opened
* https://issues.apache.org/struts/browse/WW-2191
for this, and noted the setting in the Validators documentation.
Thanks for pointing this out, Veronica!
-Ted.
On 8/10/07, Veronica Iturrioz <vi...@yahoo.com> wrote:
> You must to set the property validateAnnotatedMethodOnly=true, and the validation occurs only for the correct methods.
>
> <interceptor-ref name="validation">
> <param name="validateAnnotatedMethodOnly">true</param>
> <param name="excludeMethods">input,back,cancel,browse</param>
> </interceptor-ref>
>
> but this is ok for server validation, not for client validation.
> Anybody know how to resolve that for client validations?
>
>
> Veronica.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: S2 : Validation per Action method - ideas?
Posted by Ted Husted <hu...@apache.org>.
With some work, the annotations could be as flexible as the XML
validations. The messy problem in either case is being able to express
when and when-not to inherit validations from parent classes.
Right now, you can shut off the inheritance of validations (as
Veronica described), but it shuts off all inheritance, even "property"
validations" on parent classes. In turn, this is awkward since it can
be convenient to have one place to declare the format of a field (e.g.
email) whenever it is used.
In my own work, I'm getting away from aliases and tending to use more
classes. Where I might have used a class with multiple method before,
I've added a package with multiple classes. For now, this paradigm
seems to work better with the existing validation annotations.
Add in the ActionNames and ActionName annotations frrom the SmartURLs
plugin, and it becomes possible to write non-trivial Struts 2
applications using only conventions and annotations (connotations?) :)
It doesn't use multiple packages, but I have just finished a draft of
a Zero Configuration MailReader. There isn't any kind of a
distribution yet, but it can be obtained from SVN:
* http://sq1-struts2.googlecode.com/svn/trunk/articles/mailreader-zero/
All the JARs are checked in, and it shouldn't be hard to import the
project into any given IDE.
Of course, there are many people who prefer to use multiple methods. I
expect that the annotations could be extended to better support action
aliases, but we need more volunteers to do the work.
HTH, Ted
<http://www.husted.com/ted/blog/>
On 9/18/07, David Harland <dh...@ufi.com> wrote:
> Hi Ted,
>
> It appears that if you use annotations you have more flexibilty than
> with using xml. Would it not be possible to add the abililty to specify
> validation files for each method without having to create aliases for
> every single method. We have actions with quite a high number of methods
> each wanting different validation. This can get messy.
>
>
> Regards
>
> David
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Validation in showcase examples
Posted by Dean Pullen <de...@msp-uk.com>.
Not sure what your feelings are, but I've noticed the showcase
application example uses the commons validator for validation.
Would it make more sense for the validation (what little there is in
that app) to be changed to use the Xworks validator, considering this is
what the Struts 2 documentation gives a tutorial on?
(I did notice that the mailreader app used the Xworks validator so maybe
this is just a way of showing multiple validation framework
possibilities?)
Dean.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: S2 : Validation per Action method - ideas?
Posted by David Harland <dh...@ufi.com>.
<s:form>
<s:submit key="buy.key" method="buy"/>
<s:submit key="sell.key" method="sell"/> </s:form>
<action name="auction" class="my.AuctionAction">
<result>/auction.jsp</result>
</action>
public class AuctionAction {
public String buy() {
return SUCCESS;
}
public String sell() {
return SUCCESS;
}
}
Consider this code. It would be preferable to be able to write a
separate validation xml for each of the above methods. E.g.
AuctionAction-sell-validation.xml
AuctionAction-buy-validation.xml
Presently Struts 2 seems to ignore the method name if it is
non-annotated action. Are we missing something here? It seems the only
way to get this to work would be to change the jsp and struts xml as
follows:
<s:form>
<s:submit key="buy.key" action="auctionbuy" method="buy"/>
<s:submit key="sell.key" action="auctionsell" method="sell"/>
</s:form>
<action name="auction*" class="my.AuctionAction">
<result>/auction.jsp</result>
</action>
With validation named as follows:
AuctionAction-auctionsell-validation.xml
AuctionAction-auctionbuy-validation.xml
This has a downside that we have to hardcode the action alias in the JSP
which limits the reuse of a JSP that maybe used by more than one action.
-----Original Message-----
From: cilquirm [mailto:aadi.deshpande@gmail.com]
Sent: 18 September 2007 15:41
To: user@struts.apache.org
Subject: RE: S2 : Validation per Action method - ideas?
I'm not sure I follow how validation is more flexible when using
annotations vs. xml files.
Aliases are how you tell xwork that this method is the one to be
executed, so there's a 1-to-1 mapping between aliases and methods.
File based validation is, in a sense, more flexible, because you can
define multiple aliases against a single method and specify different
rules for each of those.
If you could provide more information regarding your situation, that
would be of great insight.
Thanks,
-a
David Harland-3 wrote:
>
> Hi Ted,
>
> It appears that if you use annotations you have more flexibilty than
> with using xml. Would it not be possible to add the abililty to
> specify validation files for each method without having to create
> aliases for every single method. We have actions with quite a high
> number of methods each wanting different validation. This can get
messy.
>
>
> Regards
>
> David
>
> -----Original Message-----
> From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
> Ted Husted
> Sent: 18 September 2007 11:12
> To: Struts Users Mailing List
> Subject: Re: S2 : Validation per Action method - ideas?
>
> * http://struts.apache.org/2.x/docs/validation.html
>
> It's under "Defining Validation Rules" at 2. The term "alias" is used
> to refer to the action method.
>
> So if there's an actions.Register.java class with "insert" and
"update"
> action methods, then there might be XML docs like
>
> /java/actions/Register-insert-validations.xml
> /java/actions/Register-update-validations.xml
>
> One would only file for the insert method and the other only for the
> update method.
>
> The framework makes the association automatically, based on the naming
> convention, so there's nothing else to configure.
>
> In WebWork in Action, it's at page 353-354, under "Validation under
> different contexts".
>
> HTH, Ted
> <http://www.husted.com/ted/blog/>
>
>
> On 9/18/07, David Harland <dh...@ufi.com> wrote:
>> Can someone please point me to the documentation that shows you how
>> to
>
>> configure validation per action method using the validation xml
files?
>> Or is this not possible?
>>
>> -----Original Message-----
>> From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
>> Ted Husted
>> Sent: 18 September 2007 10:27
>> To: Struts Users Mailing List
>> Cc: viturrioz@yahoo.com
>> Subject: Re: S2 : Validation per Action method - ideas?
>>
>> I opened
>>
>> * https://issues.apache.org/struts/browse/WW-2191
>>
>> for this, and noted the setting in the Validators documentation.
>>
>> Thanks for pointing this out, Veronica!
>>
>> -Ted.
>>
>> On 8/10/07, Veronica Iturrioz <vi...@yahoo.com> wrote:
>> > You must to set the property validateAnnotatedMethodOnly=true, and
>> > the
>> validation occurs only for the correct methods.
>> >
>> > <interceptor-ref name="validation">
>> > true
>> > input,back,cancel,browse
>> > </interceptor-ref>
>> >
>> > but this is ok for server validation, not for client validation.
>> > Anybody know how to resolve that for client validations?
>> >
>> >
>> > Veronica.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> - ------
> ML {UFI}
>
> ______________________________________________________________________
> Ufi Limited
> Registered in England No. 3980770
> Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
>
> learndirect Solutions Ltd
> Registered in England No. 5081669
> Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
>
> UFI Charitable Trust
> Registered in England No. 3658378
> Registered Charity No. 1081028
> Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
>
> This email has been scanned by the MessageLabs Email Security System.
>
> ______________________________________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context:
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf424
2670.html#a12758403
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
- ------
ML {UFI}
______________________________________________________________________
Ufi Limited
Registered in England No. 3980770
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
learndirect Solutions Ltd
Registered in England No. 5081669
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
UFI Charitable Trust
Registered in England No. 3658378
Registered Charity No. 1081028
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: S2 : Validation per Action method - ideas?
Posted by cilquirm <aa...@gmail.com>.
I'm not sure I follow how validation is more flexible when using annotations
vs. xml files.
Aliases are how you tell xwork that this method is the one to be executed,
so there's a 1-to-1 mapping between aliases and methods.
File based validation is, in a sense, more flexible, because you can define
multiple aliases against a single method and specify different rules for
each of those.
If you could provide more information regarding your situation, that would
be of great insight.
Thanks,
-a
David Harland-3 wrote:
>
> Hi Ted,
>
> It appears that if you use annotations you have more flexibilty than
> with using xml. Would it not be possible to add the abililty to specify
> validation files for each method without having to create aliases for
> every single method. We have actions with quite a high number of methods
> each wanting different validation. This can get messy.
>
>
> Regards
>
> David
>
> -----Original Message-----
> From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
> Ted Husted
> Sent: 18 September 2007 11:12
> To: Struts Users Mailing List
> Subject: Re: S2 : Validation per Action method - ideas?
>
> * http://struts.apache.org/2.x/docs/validation.html
>
> It's under "Defining Validation Rules" at 2. The term "alias" is used to
> refer to the action method.
>
> So if there's an actions.Register.java class with "insert" and "update"
> action methods, then there might be XML docs like
>
> /java/actions/Register-insert-validations.xml
> /java/actions/Register-update-validations.xml
>
> One would only file for the insert method and the other only for the
> update method.
>
> The framework makes the association automatically, based on the naming
> convention, so there's nothing else to configure.
>
> In WebWork in Action, it's at page 353-354, under "Validation under
> different contexts".
>
> HTH, Ted
> <http://www.husted.com/ted/blog/>
>
>
> On 9/18/07, David Harland <dh...@ufi.com> wrote:
>> Can someone please point me to the documentation that shows you how to
>
>> configure validation per action method using the validation xml files?
>> Or is this not possible?
>>
>> -----Original Message-----
>> From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
>> Ted Husted
>> Sent: 18 September 2007 10:27
>> To: Struts Users Mailing List
>> Cc: viturrioz@yahoo.com
>> Subject: Re: S2 : Validation per Action method - ideas?
>>
>> I opened
>>
>> * https://issues.apache.org/struts/browse/WW-2191
>>
>> for this, and noted the setting in the Validators documentation.
>>
>> Thanks for pointing this out, Veronica!
>>
>> -Ted.
>>
>> On 8/10/07, Veronica Iturrioz <vi...@yahoo.com> wrote:
>> > You must to set the property validateAnnotatedMethodOnly=true, and
>> > the
>> validation occurs only for the correct methods.
>> >
>> > <interceptor-ref name="validation">
>> > true
>> > input,back,cancel,browse
>> > </interceptor-ref>
>> >
>> > but this is ok for server validation, not for client validation.
>> > Anybody know how to resolve that for client validations?
>> >
>> >
>> > Veronica.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> - ------
> ML {UFI}
>
> ______________________________________________________________________
> Ufi Limited
> Registered in England No. 3980770
> Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
>
> learndirect Solutions Ltd
> Registered in England No. 5081669
> Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
>
> UFI Charitable Trust
> Registered in England No. 3658378
> Registered Charity No. 1081028
> Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
>
> This email has been scanned by the MessageLabs Email Security System.
>
> ______________________________________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670.html#a12758403
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: S2 : Validation per Action method - ideas?
Posted by David Harland <dh...@ufi.com>.
Hi Ted,
It appears that if you use annotations you have more flexibilty than
with using xml. Would it not be possible to add the abililty to specify
validation files for each method without having to create aliases for
every single method. We have actions with quite a high number of methods
each wanting different validation. This can get messy.
Regards
David
-----Original Message-----
From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
Ted Husted
Sent: 18 September 2007 11:12
To: Struts Users Mailing List
Subject: Re: S2 : Validation per Action method - ideas?
* http://struts.apache.org/2.x/docs/validation.html
It's under "Defining Validation Rules" at 2. The term "alias" is used to
refer to the action method.
So if there's an actions.Register.java class with "insert" and "update"
action methods, then there might be XML docs like
/java/actions/Register-insert-validations.xml
/java/actions/Register-update-validations.xml
One would only file for the insert method and the other only for the
update method.
The framework makes the association automatically, based on the naming
convention, so there's nothing else to configure.
In WebWork in Action, it's at page 353-354, under "Validation under
different contexts".
HTH, Ted
<http://www.husted.com/ted/blog/>
On 9/18/07, David Harland <dh...@ufi.com> wrote:
> Can someone please point me to the documentation that shows you how to
> configure validation per action method using the validation xml files?
> Or is this not possible?
>
> -----Original Message-----
> From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
> Ted Husted
> Sent: 18 September 2007 10:27
> To: Struts Users Mailing List
> Cc: viturrioz@yahoo.com
> Subject: Re: S2 : Validation per Action method - ideas?
>
> I opened
>
> * https://issues.apache.org/struts/browse/WW-2191
>
> for this, and noted the setting in the Validators documentation.
>
> Thanks for pointing this out, Veronica!
>
> -Ted.
>
> On 8/10/07, Veronica Iturrioz <vi...@yahoo.com> wrote:
> > You must to set the property validateAnnotatedMethodOnly=true, and
> > the
> validation occurs only for the correct methods.
> >
> > <interceptor-ref name="validation">
> > <param name="validateAnnotatedMethodOnly">true</param>
> > <param name="excludeMethods">input,back,cancel,browse</param>
> > </interceptor-ref>
> >
> > but this is ok for server validation, not for client validation.
> > Anybody know how to resolve that for client validations?
> >
> >
> > Veronica.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
- ------
ML {UFI}
______________________________________________________________________
Ufi Limited
Registered in England No. 3980770
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
learndirect Solutions Ltd
Registered in England No. 5081669
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
UFI Charitable Trust
Registered in England No. 3658378
Registered Charity No. 1081028
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: S2 : Validation per Action method - ideas?
Posted by Ted Husted <hu...@apache.org>.
* http://struts.apache.org/2.x/docs/validation.html
It's under "Defining Validation Rules" at 2. The term "alias" is used
to refer to the action method.
So if there's an actions.Register.java class with "insert" and
"update" action methods, then there might be XML docs like
/java/actions/Register-insert-validations.xml
/java/actions/Register-update-validations.xml
One would only file for the insert method and the other only for the
update method.
The framework makes the association automatically, based on the naming
convention, so there's nothing else to configure.
In WebWork in Action, it's at page 353-354, under "Validation under
different contexts".
HTH, Ted
<http://www.husted.com/ted/blog/>
On 9/18/07, David Harland <dh...@ufi.com> wrote:
> Can someone please point me to the documentation that shows you how to
> configure validation per action method using the validation xml files?
> Or is this not possible?
>
> -----Original Message-----
> From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
> Ted Husted
> Sent: 18 September 2007 10:27
> To: Struts Users Mailing List
> Cc: viturrioz@yahoo.com
> Subject: Re: S2 : Validation per Action method - ideas?
>
> I opened
>
> * https://issues.apache.org/struts/browse/WW-2191
>
> for this, and noted the setting in the Validators documentation.
>
> Thanks for pointing this out, Veronica!
>
> -Ted.
>
> On 8/10/07, Veronica Iturrioz <vi...@yahoo.com> wrote:
> > You must to set the property validateAnnotatedMethodOnly=true, and the
> validation occurs only for the correct methods.
> >
> > <interceptor-ref name="validation">
> > <param name="validateAnnotatedMethodOnly">true</param>
> > <param name="excludeMethods">input,back,cancel,browse</param>
> > </interceptor-ref>
> >
> > but this is ok for server validation, not for client validation.
> > Anybody know how to resolve that for client validations?
> >
> >
> > Veronica.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: S2 : Validation per Action method - ideas?
Posted by David Harland <dh...@ufi.com>.
Can someone please point me to the documentation that shows you how to
configure validation per action method using the validation xml files?
Or is this not possible?
-----Original Message-----
From: ted.husted@gmail.com [mailto:ted.husted@gmail.com] On Behalf Of
Ted Husted
Sent: 18 September 2007 10:27
To: Struts Users Mailing List
Cc: viturrioz@yahoo.com
Subject: Re: S2 : Validation per Action method - ideas?
I opened
* https://issues.apache.org/struts/browse/WW-2191
for this, and noted the setting in the Validators documentation.
Thanks for pointing this out, Veronica!
-Ted.
On 8/10/07, Veronica Iturrioz <vi...@yahoo.com> wrote:
> You must to set the property validateAnnotatedMethodOnly=true, and the
validation occurs only for the correct methods.
>
> <interceptor-ref name="validation">
> <param name="validateAnnotatedMethodOnly">true</param>
> <param name="excludeMethods">input,back,cancel,browse</param>
> </interceptor-ref>
>
> but this is ok for server validation, not for client validation.
> Anybody know how to resolve that for client validations?
>
>
> Veronica.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
- ------
ML {UFI}
______________________________________________________________________
Ufi Limited
Registered in England No. 3980770
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
learndirect Solutions Ltd
Registered in England No. 5081669
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
UFI Charitable Trust
Registered in England No. 3658378
Registered Charity No. 1081028
Registered Office: Dearing House, 1 Young Street, Sheffield, S1 4UP
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org