RE: S2 : Validation per Action method - ideas?

2007-10-17 Thread shan99

I got a problem like  this

I have 2 mothods caled edit() and create() I used annotation based
validation
but tthing is i want to validate some of experssions in edit method and some
of the in create() method
cant use @skipValidation in this
my problem is i can not difine this seperatly in my actiion class ..both
methods get validate from all expressions? any 1 have a ida?
-- 
View this message in context: 
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670.html#a13249097
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-10-17 Thread Dean Pullen
I suspect you should create two action classes for this kind of
validation.
Either that, or over-ride the validation (and don't use the annotations)
using the validation() method.

-Original Message-
From: shan99 [mailto:[EMAIL PROTECTED] 
Sent: 17 October 2007 09:27
To: user@struts.apache.org
Subject: RE: S2 : Validation per Action method - ideas?


I got a problem like  this

I have 2 mothods caled edit() and create() I used annotation based
validation
but tthing is i want to validate some of experssions in edit method and
some
of the in create() method
cant use @skipValidation in this
my problem is i can not difine this seperatly in my actiion class ..both
methods get validate from all expressions? any 1 have a ida?
-- 
View this message in context:
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf424
2670.html#a13249097
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Scanned by MailDefender - managed email security from intY -
www.maildefender.net

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-10-17 Thread beto

You should have a look at this one:

http://www.nabble.com/Re%3A-S2-%3A-Validation-per-Action-method---ideas--p12753992.html

I ended up following this lead, and it works nice.

Or you could try this:

http://www.nabble.com/Re%3A-S2-%3A-Validation-per-Action-method---ideas--p12090749.html

beto


shan99 wrote:
 
 I got a problem like  this
 
 I have 2 mothods caled edit() and create() I used annotation based
 validation
 but tthing is i want to validate some of experssions in edit method and
 some of the in create() method
 cant use @skipValidation in this
 my problem is i can not difine this seperatly in my actiion class ..both
 methods get validate from all expressions? any 1 have a ida?
 

-- 
View this message in context: 
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670.html#a13249318
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: S2 : Validation per Action method - ideas?

2007-09-18 Thread Ted Husted
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 [EMAIL PROTECTED] wrote:
 You must to set the property validateAnnotatedMethodOnly=true, and the 
 validation occurs only for the correct methods.

 interceptor-ref name=validation
 param name=validateAnnotatedMethodOnlytrue/param
 param name=excludeMethodsinput,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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-09-18 Thread David Harland
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Ted Husted
Sent: 18 September 2007 10:27
To: Struts Users Mailing List
Cc: [EMAIL PROTECTED]
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 [EMAIL PROTECTED] wrote:
 You must to set the property validateAnnotatedMethodOnly=true, and the
validation occurs only for the correct methods.

 interceptor-ref name=validation
 param name=validateAnnotatedMethodOnlytrue/param
 param name=excludeMethodsinput,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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


- --
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: S2 : Validation per Action method - ideas?

2007-09-18 Thread Ted Husted
 * 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
 Ted Husted
 Sent: 18 September 2007 10:27
 To: Struts Users Mailing List
 Cc: [EMAIL PROTECTED]
 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 [EMAIL PROTECTED] wrote:
  You must to set the property validateAnnotatedMethodOnly=true, and the
 validation occurs only for the correct methods.
 
  interceptor-ref name=validation
  param name=validateAnnotatedMethodOnlytrue/param
  param name=excludeMethodsinput,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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-09-18 Thread David Harland
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of 
 Ted Husted
 Sent: 18 September 2007 10:27
 To: Struts Users Mailing List
 Cc: [EMAIL PROTECTED]
 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 [EMAIL PROTECTED] wrote:
  You must to set the property validateAnnotatedMethodOnly=true, and 
  the
 validation occurs only for the correct methods.
 
  interceptor-ref name=validation
  param name=validateAnnotatedMethodOnlytrue/param
  param name=excludeMethodsinput,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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


- --
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-09-18 Thread cilquirm

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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of 
 Ted Husted
 Sent: 18 September 2007 10:27
 To: Struts Users Mailing List
 Cc: [EMAIL PROTECTED]
 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 - --
 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-09-18 Thread David Harland
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:[EMAIL PROTECTED] 
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of

 Ted Husted
 Sent: 18 September 2007 10:27
 To: Struts Users Mailing List
 Cc: [EMAIL PROTECTED]
 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 - --
 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

Re: S2 : Validation per Action method - ideas?

2007-09-18 Thread Ted Husted
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-08-10 Thread beto

Hi again, and thank you for your answer.

I've tried using @Validations at the method level as you point out. I'll try
to illustrate:

I have an action, not annotated with @Validation, with three action methods;
input, execute and confirm (custom action method).

The input method has no annotations and is not validated as expected.

The execute method is annotated with @Validations:

@Validations(requiredStrings={  @RequiredStringValidator(fieldName=amount,
message=Amount is required, key=amount.required) }, regexFields={
@RegexFieldValidator(fieldName=amount, expression=^\\d+$,
message=Amount has to be numeric, key=amount.numeric) })
public String execute() throws Exception {
  ...
}

The confirm method is also annotated with @Validations:

@Validations(expressions={ @ExpressionValidator(expression=confirm ==
true, message=test) })
public String confirm() throws Exception {
  ...
}

And here comes the confusing part. When I call my action with no method name
indicator (say MyAction, not MyAction_confirm), both fields (amount and
confirm) is validated. I just want to validate amount when execute is
called and only the field confirm when the confirm method is called.

What am I doing wrong?

beto


Arno wrote:
 
 This is the Validations (with a 's' at the end :-) ) that can be put on a
 method. The syntax is pretty confusing but the functionality quite neat.
 
 http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va
 lidator/annotations/Validations.html
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 10:57
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi.
 
 I've tried using validation annotation (which works great) and ran into
 the
 scenario mentioned by Joseph. I have different action methods which
 requires
 different set of validation rules. I can not find out how to set up
 validation annotation to differentiate the validation rules based on which
 action method that is called. I do not wish to use validation xml-files if
 I
 can avoid it, and will probably end up creating separate action classes in
 these scenarios if not anybody can point out a solution to this problem.
 
 Am I missing something?
 
 Do you have the solution Arno? :-) 
 
 
 Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = stringisrequired, message = You must enter a value for
 string.)}
  
  )
  public String execute() throws Exception {
  return SUCCESS;
  }
 
 -Message d'origine-
 De : j alex [mailto:[EMAIL PROTECTED] 
 Envoyé : jeudi 9 août 2007 15:38
 À : Struts Users Mailing List
 Objet : S2 : Validation per Action method - ideas?
 
 Hi,
 
 Is there a way to declaratively restrict validations depending on the
 method
 within the Action? - this could be useful for wizard-like forms where
 each
 step of the wizard has a set of fields ; corresponds to a different
 method
 but all of them share the same Action.
 
 I can think of having an expression validator based on currentstep added
 to
 every field short-circuited ; but that's more of a workaround rather than
 the right way to do it.
 
 Thanks,
 Joseph
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 View this message in context:
 http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670
 .html#a12087696
 Sent from the Struts - User mailing list archive at Nabble.com.
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670.html#a12088476
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-08-10 Thread beto

Yes, I removed the annotations from the setters. I might be overlooking
something, but I'm not sure where to start looking at this moment. Is there
any more details I could provide to help you see the clear picture?


Arno wrote:
 
 Pretty strange indeed. Did you remove all the validation annotations on
 the
 field setters?
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 11:56
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi again, and thank you for your answer.
 
 I've tried using @Validations at the method level as you point out. I'll
 try
 to illustrate:
 
 I have an action, not annotated with @Validation, with three action
 methods;
 input, execute and confirm (custom action method).
 
 The input method has no annotations and is not validated as expected.
 
 The execute method is annotated with @Validations:
 
 @Validations(requiredStrings={
 @RequiredStringValidator(fieldName=amount,
 message=Amount is required, key=amount.required) }, regexFields={
 @RegexFieldValidator(fieldName=amount, expression=^\\d+$,
 message=Amount has to be numeric, key=amount.numeric) })
 public String execute() throws Exception {
   ...
 }
 
 The confirm method is also annotated with @Validations:
 
 @Validations(expressions={ @ExpressionValidator(expression=confirm ==
 true, message=test) })
 public String confirm() throws Exception {
   ...
 }
 
 And here comes the confusing part. When I call my action with no method
 name
 indicator (say MyAction, not MyAction_confirm), both fields (amount and
 confirm) is validated. I just want to validate amount when execute is
 called and only the field confirm when the confirm method is called.
 
 What am I doing wrong?
 
 beto
 
 
 Arno wrote:
 
 This is the Validations (with a 's' at the end :-) ) that can be put on a
 method. The syntax is pretty confusing but the functionality quite neat.
 

 http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va
 lidator/annotations/Validations.html
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 10:57
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi.
 
 I've tried using validation annotation (which works great) and ran into
 the
 scenario mentioned by Joseph. I have different action methods which
 requires
 different set of validation rules. I can not find out how to set up
 validation annotation to differentiate the validation rules based on
 which
 action method that is called. I do not wish to use validation xml-files
 if
 I
 can avoid it, and will probably end up creating separate action classes
 in
 these scenarios if not anybody can point out a solution to this problem.
 
 Am I missing something?
 
 Do you have the solution Arno? :-) 
 
 
 Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = stringisrequired, message = You must enter a value for
 string.)}
  
  )
  public String execute() throws Exception {
  return SUCCESS;
  }
 
 -Message d'origine-
 De : j alex [mailto:[EMAIL PROTECTED] 
 Envoyé : jeudi 9 août 2007 15:38
 À : Struts Users Mailing List
 Objet : S2 : Validation per Action method - ideas?
 
 Hi,
 
 Is there a way to declaratively restrict validations depending on the
 method
 within the Action? - this could be useful for wizard-like forms where
 each
 step of the wizard has a set of fields ; corresponds to a different
 method
 but all of them share the same Action.
 
 I can think of having an expression validator based on currentstep added
 to
 every field short-circuited ; but that's more of a workaround rather
 than
 the right way to do it.
 
 Thanks,
 Joseph
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 View this message in context:

 http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670
 .html#a12087696
 Sent from the Struts - User mailing list archive at Nabble.com.
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 View this message in context:
 http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670

Re: S2 : Validation per Action method - ideas?

2007-08-10 Thread Veronica Iturrioz
You must to set the property validateAnnotatedMethodOnly=true, and the 
validation occurs only for the correct methods.

interceptor-ref name=validation
param name=validateAnnotatedMethodOnlytrue/param
param name=excludeMethodsinput,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.

- Original Message 
From: beto [EMAIL PROTECTED]
To: user@struts.apache.org
Sent: Friday, August 10, 2007 8:54:02 AM
Subject: RE: S2 : Validation per Action method - ideas?


I tried removing annotations from the execute method, and the field confirm
is still getting validated. It seems like any validation annotation added in
my action causes validation of the defined fields whenever a method not
defined in the validation interceptor configuration (methods excluded from
validation) is called. 

Could it be that I'm trying to do something that is not supported? I'll have
another go on google. Found this post in this list, so it looks like I'm not
alone:

http://www.nabble.com/S2-%3A-XML-vs-annotation-validation---thoughts--tf4229633.html#a12032762
post 


Arno wrote:
 
 Well, looking at my code using Validations on methods, I noticed that I
 used
 it only on one method and used @SkipValidation on my other action methods
 (which worked). So I did not try the multi validations scenario.
 
 Just to test, let the validations annotation on only one method and check
 what happens.
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 13:21
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Yes, I removed the annotations from the setters. I might be overlooking
 something, but I'm not sure where to start looking at this moment. Is
 there
 any more details I could provide to help you see the clear picture?
 
 
 Arno wrote:
 
 Pretty strange indeed. Did you remove all the validation annotations on
 the
 field setters?
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 11:56
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi again, and thank you for your answer.
 
 I've tried using @Validations at the method level as you point out. I'll
 try
 to illustrate:
 
 I have an action, not annotated with @Validation, with three action
 methods;
 input, execute and confirm (custom action method).
 
 The input method has no annotations and is not validated as expected.
 
 The execute method is annotated with @Validations:
 
 @Validations(requiredStrings={
 @RequiredStringValidator(fieldName=amount,
 message=Amount is required, key=amount.required) }, regexFields={
 @RegexFieldValidator(fieldName=amount, expression=^\\d+$,
 message=Amount has to be numeric, key=amount.numeric) })
 public String execute() throws Exception {
   ...
 }
 
 The confirm method is also annotated with @Validations:
 
 @Validations(expressions={ @ExpressionValidator(expression=confirm ==
 true, message=test) })
 public String confirm() throws Exception {
   ...
 }
 
 And here comes the confusing part. When I call my action with no method
 name
 indicator (say MyAction, not MyAction_confirm), both fields (amount and
 confirm) is validated. I just want to validate amount when execute is
 called and only the field confirm when the confirm method is called.
 
 What am I doing wrong?
 
 beto
 
 
 Arno wrote:
 
 This is the Validations (with a 's' at the end :-) ) that can be put on
 a
 method. The syntax is pretty confusing but the functionality quite neat.
 


 http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va
 lidator/annotations/Validations.html
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 10:57
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi.
 
 I've tried using validation annotation (which works great) and ran into
 the
 scenario mentioned by Joseph. I have different action methods which
 requires
 different set of validation rules. I can not find out how to set up
 validation annotation to differentiate the validation rules based on
 which
 action method that is called. I do not wish to use validation xml-files
 if
 I
 can avoid it, and will probably end up creating separate action classes
 in
 these scenarios if not anybody can point out a solution to this problem.
 
 Am I missing something?
 
 Do you have the solution Arno? :-) 
 
 
 Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED

RE: S2 : Validation per Action method - ideas?

2007-08-10 Thread beto

I tried removing annotations from the execute method, and the field confirm
is still getting validated. It seems like any validation annotation added in
my action causes validation of the defined fields whenever a method not
defined in the validation interceptor configuration (methods excluded from
validation) is called. 

Could it be that I'm trying to do something that is not supported? I'll have
another go on google. Found this post in this list, so it looks like I'm not
alone:

http://www.nabble.com/S2-%3A-XML-vs-annotation-validation---thoughts--tf4229633.html#a12032762
post 


Arno wrote:
 
 Well, looking at my code using Validations on methods, I noticed that I
 used
 it only on one method and used @SkipValidation on my other action methods
 (which worked). So I did not try the multi validations scenario.
 
 Just to test, let the validations annotation on only one method and check
 what happens.
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 13:21
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Yes, I removed the annotations from the setters. I might be overlooking
 something, but I'm not sure where to start looking at this moment. Is
 there
 any more details I could provide to help you see the clear picture?
 
 
 Arno wrote:
 
 Pretty strange indeed. Did you remove all the validation annotations on
 the
 field setters?
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 11:56
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi again, and thank you for your answer.
 
 I've tried using @Validations at the method level as you point out. I'll
 try
 to illustrate:
 
 I have an action, not annotated with @Validation, with three action
 methods;
 input, execute and confirm (custom action method).
 
 The input method has no annotations and is not validated as expected.
 
 The execute method is annotated with @Validations:
 
 @Validations(requiredStrings={
 @RequiredStringValidator(fieldName=amount,
 message=Amount is required, key=amount.required) }, regexFields={
 @RegexFieldValidator(fieldName=amount, expression=^\\d+$,
 message=Amount has to be numeric, key=amount.numeric) })
 public String execute() throws Exception {
   ...
 }
 
 The confirm method is also annotated with @Validations:
 
 @Validations(expressions={ @ExpressionValidator(expression=confirm ==
 true, message=test) })
 public String confirm() throws Exception {
   ...
 }
 
 And here comes the confusing part. When I call my action with no method
 name
 indicator (say MyAction, not MyAction_confirm), both fields (amount and
 confirm) is validated. I just want to validate amount when execute is
 called and only the field confirm when the confirm method is called.
 
 What am I doing wrong?
 
 beto
 
 
 Arno wrote:
 
 This is the Validations (with a 's' at the end :-) ) that can be put on
 a
 method. The syntax is pretty confusing but the functionality quite neat.
 


 http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va
 lidator/annotations/Validations.html
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 10:57
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi.
 
 I've tried using validation annotation (which works great) and ran into
 the
 scenario mentioned by Joseph. I have different action methods which
 requires
 different set of validation rules. I can not find out how to set up
 validation annotation to differentiate the validation rules based on
 which
 action method that is called. I do not wish to use validation xml-files
 if
 I
 can avoid it, and will probably end up creating separate action classes
 in
 these scenarios if not anybody can point out a solution to this problem.
 
 Am I missing something?
 
 Do you have the solution Arno? :-) 
 
 
 Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = stringisrequired, message = You must enter a value for
 string.)}
  
  )
  public String execute() throws Exception {
  return SUCCESS;
  }
 
 -Message d'origine-
 De : j alex [mailto:[EMAIL PROTECTED] 
 Envoyé : jeudi 9 août 2007 15:38
 À : Struts Users Mailing List
 Objet : S2 : Validation per Action method - ideas?
 
 Hi,
 
 Is there a way to declaratively restrict validations depending on the
 method
 within the Action? - this could be useful for wizard-like forms where
 each
 step of the wizard has a set of fields

RE: S2 : Validation per Action method - ideas?

2007-08-10 Thread Arnaud Cogoluegnes
Well, looking at my code using Validations on methods, I noticed that I used
it only on one method and used @SkipValidation on my other action methods
(which worked). So I did not try the multi validations scenario.

Just to test, let the validations annotation on only one method and check
what happens.

-Message d'origine-
De : beto [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 10 août 2007 13:21
À : user@struts.apache.org
Objet : RE: S2 : Validation per Action method - ideas?


Yes, I removed the annotations from the setters. I might be overlooking
something, but I'm not sure where to start looking at this moment. Is there
any more details I could provide to help you see the clear picture?


Arno wrote:
 
 Pretty strange indeed. Did you remove all the validation annotations on
 the
 field setters?
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 11:56
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi again, and thank you for your answer.
 
 I've tried using @Validations at the method level as you point out. I'll
 try
 to illustrate:
 
 I have an action, not annotated with @Validation, with three action
 methods;
 input, execute and confirm (custom action method).
 
 The input method has no annotations and is not validated as expected.
 
 The execute method is annotated with @Validations:
 
 @Validations(requiredStrings={
 @RequiredStringValidator(fieldName=amount,
 message=Amount is required, key=amount.required) }, regexFields={
 @RegexFieldValidator(fieldName=amount, expression=^\\d+$,
 message=Amount has to be numeric, key=amount.numeric) })
 public String execute() throws Exception {
   ...
 }
 
 The confirm method is also annotated with @Validations:
 
 @Validations(expressions={ @ExpressionValidator(expression=confirm ==
 true, message=test) })
 public String confirm() throws Exception {
   ...
 }
 
 And here comes the confusing part. When I call my action with no method
 name
 indicator (say MyAction, not MyAction_confirm), both fields (amount and
 confirm) is validated. I just want to validate amount when execute is
 called and only the field confirm when the confirm method is called.
 
 What am I doing wrong?
 
 beto
 
 
 Arno wrote:
 
 This is the Validations (with a 's' at the end :-) ) that can be put on a
 method. The syntax is pretty confusing but the functionality quite neat.
 


http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va
 lidator/annotations/Validations.html
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 10:57
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi.
 
 I've tried using validation annotation (which works great) and ran into
 the
 scenario mentioned by Joseph. I have different action methods which
 requires
 different set of validation rules. I can not find out how to set up
 validation annotation to differentiate the validation rules based on
 which
 action method that is called. I do not wish to use validation xml-files
 if
 I
 can avoid it, and will probably end up creating separate action classes
 in
 these scenarios if not anybody can point out a solution to this problem.
 
 Am I missing something?
 
 Do you have the solution Arno? :-) 
 
 
 Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = stringisrequired, message = You must enter a value for
 string.)}
  
  )
  public String execute() throws Exception {
  return SUCCESS;
  }
 
 -Message d'origine-
 De : j alex [mailto:[EMAIL PROTECTED] 
 Envoyé : jeudi 9 août 2007 15:38
 À : Struts Users Mailing List
 Objet : S2 : Validation per Action method - ideas?
 
 Hi,
 
 Is there a way to declaratively restrict validations depending on the
 method
 within the Action? - this could be useful for wizard-like forms where
 each
 step of the wizard has a set of fields ; corresponds to a different
 method
 but all of them share the same Action.
 
 I can think of having an expression validator based on currentstep added
 to
 every field short-circuited ; but that's more of a workaround rather
 than
 the right way to do it.
 
 Thanks,
 Joseph
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 View this message in context:


http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670
 .html#a12087696
 Sent from the Struts - User mailing list

RE: S2 : Validation per Action method - ideas?

2007-08-10 Thread Arnaud Cogoluegnes
Pretty strange indeed. Did you remove all the validation annotations on the
field setters?

-Message d'origine-
De : beto [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 10 août 2007 11:56
À : user@struts.apache.org
Objet : RE: S2 : Validation per Action method - ideas?


Hi again, and thank you for your answer.

I've tried using @Validations at the method level as you point out. I'll try
to illustrate:

I have an action, not annotated with @Validation, with three action methods;
input, execute and confirm (custom action method).

The input method has no annotations and is not validated as expected.

The execute method is annotated with @Validations:

@Validations(requiredStrings={  @RequiredStringValidator(fieldName=amount,
message=Amount is required, key=amount.required) }, regexFields={
@RegexFieldValidator(fieldName=amount, expression=^\\d+$,
message=Amount has to be numeric, key=amount.numeric) })
public String execute() throws Exception {
  ...
}

The confirm method is also annotated with @Validations:

@Validations(expressions={ @ExpressionValidator(expression=confirm ==
true, message=test) })
public String confirm() throws Exception {
  ...
}

And here comes the confusing part. When I call my action with no method name
indicator (say MyAction, not MyAction_confirm), both fields (amount and
confirm) is validated. I just want to validate amount when execute is
called and only the field confirm when the confirm method is called.

What am I doing wrong?

beto


Arno wrote:
 
 This is the Validations (with a 's' at the end :-) ) that can be put on a
 method. The syntax is pretty confusing but the functionality quite neat.
 

http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va
 lidator/annotations/Validations.html
 
 -Message d'origine-
 De : beto [mailto:[EMAIL PROTECTED] 
 Envoyé : vendredi 10 août 2007 10:57
 À : user@struts.apache.org
 Objet : RE: S2 : Validation per Action method - ideas?
 
 
 Hi.
 
 I've tried using validation annotation (which works great) and ran into
 the
 scenario mentioned by Joseph. I have different action methods which
 requires
 different set of validation rules. I can not find out how to set up
 validation annotation to differentiate the validation rules based on which
 action method that is called. I do not wish to use validation xml-files if
 I
 can avoid it, and will probably end up creating separate action classes in
 these scenarios if not anybody can point out a solution to this problem.
 
 Am I missing something?
 
 Do you have the solution Arno? :-) 
 
 
 Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = stringisrequired, message = You must enter a value for
 string.)}
  
  )
  public String execute() throws Exception {
  return SUCCESS;
  }
 
 -Message d'origine-
 De : j alex [mailto:[EMAIL PROTECTED] 
 Envoyé : jeudi 9 août 2007 15:38
 À : Struts Users Mailing List
 Objet : S2 : Validation per Action method - ideas?
 
 Hi,
 
 Is there a way to declaratively restrict validations depending on the
 method
 within the Action? - this could be useful for wizard-like forms where
 each
 step of the wizard has a set of fields ; corresponds to a different
 method
 but all of them share the same Action.
 
 I can think of having an expression validator based on currentstep added
 to
 every field short-circuited ; but that's more of a workaround rather than
 the right way to do it.
 
 Thanks,
 Joseph
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 View this message in context:

http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670
 .html#a12087696
 Sent from the Struts - User mailing list archive at Nabble.com.
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context:
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670
.html#a12088476
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED

RE: S2 : Validation per Action method - ideas?

2007-08-10 Thread beto

Hi.

I've tried using validation annotation (which works great) and ran into the
scenario mentioned by Joseph. I have different action methods which requires
different set of validation rules. I can not find out how to set up
validation annotation to differentiate the validation rules based on which
action method that is called. I do not wish to use validation xml-files if I
can avoid it, and will probably end up creating separate action classes in
these scenarios if not anybody can point out a solution to this problem.

Am I missing something?

Do you have the solution Arno? :-) 


Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type = ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = stringisrequired, message = You must enter a value for
 string.)}
  
  )
  public String execute() throws Exception {
  return SUCCESS;
  }
 
 -Message d'origine-
 De : j alex [mailto:[EMAIL PROTECTED] 
 Envoyé : jeudi 9 août 2007 15:38
 À : Struts Users Mailing List
 Objet : S2 : Validation per Action method - ideas?
 
 Hi,
 
 Is there a way to declaratively restrict validations depending on the
 method
 within the Action? - this could be useful for wizard-like forms where each
 step of the wizard has a set of fields ; corresponds to a different method
 but all of them share the same Action.
 
 I can think of having an expression validator based on currentstep added
 to
 every field short-circuited ; but that's more of a workaround rather than
 the right way to do it.
 
 Thanks,
 Joseph
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670.html#a12087696
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-08-10 Thread Arnaud Cogoluegnes
This is the Validations (with a 's' at the end :-) ) that can be put on a
method. The syntax is pretty confusing but the functionality quite neat.

http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va
lidator/annotations/Validations.html

-Message d'origine-
De : beto [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 10 août 2007 10:57
À : user@struts.apache.org
Objet : RE: S2 : Validation per Action method - ideas?


Hi.

I've tried using validation annotation (which works great) and ran into the
scenario mentioned by Joseph. I have different action methods which requires
different set of validation rules. I can not find out how to set up
validation annotation to differentiate the validation rules based on which
action method that is called. I do not wish to use validation xml-files if I
can avoid it, and will probably end up creating separate action classes in
these scenarios if not anybody can point out a solution to this problem.

Am I missing something?

Do you have the solution Arno? :-) 


Arno wrote:
 
 You should check the Javadoc of the
 com.opensymphony.xwork2.validator.annotations.Validation annotation.
 
 Syntax example:
 
 @Validations(
  requiredFields =
  [EMAIL PROTECTED](type = ValidatorType.SIMPLE,
 fieldName = customfield, message = You must enter a value for
 field.)},
  requiredStrings =
  [EMAIL PROTECTED](type =
 ValidatorType.SIMPLE,
 fieldName = stringisrequired, message = You must enter a value for
 string.)}
  
  )
  public String execute() throws Exception {
  return SUCCESS;
  }
 
 -Message d'origine-
 De : j alex [mailto:[EMAIL PROTECTED] 
 Envoyé : jeudi 9 août 2007 15:38
 À : Struts Users Mailing List
 Objet : S2 : Validation per Action method - ideas?
 
 Hi,
 
 Is there a way to declaratively restrict validations depending on the
 method
 within the Action? - this could be useful for wizard-like forms where each
 step of the wizard has a set of fields ; corresponds to a different method
 but all of them share the same Action.
 
 I can think of having an expression validator based on currentstep added
 to
 every field short-circuited ; but that's more of a workaround rather than
 the right way to do it.
 
 Thanks,
 Joseph
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context:
http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242670
.html#a12087696
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: S2 : Validation per Action method - ideas?

2007-08-09 Thread Arnaud Cogoluegnes
You should check the Javadoc of the
com.opensymphony.xwork2.validator.annotations.Validation annotation.

Syntax example:

@Validations(
 requiredFields =
 [EMAIL PROTECTED](type = ValidatorType.SIMPLE,
fieldName = customfield, message = You must enter a value for field.)},
 requiredStrings =
 [EMAIL PROTECTED](type = ValidatorType.SIMPLE,
fieldName = stringisrequired, message = You must enter a value for
string.)}
 
 )
 public String execute() throws Exception {
 return SUCCESS;
 }

-Message d'origine-
De : j alex [mailto:[EMAIL PROTECTED] 
Envoyé : jeudi 9 août 2007 15:38
À : Struts Users Mailing List
Objet : S2 : Validation per Action method - ideas?

Hi,

Is there a way to declaratively restrict validations depending on the method
within the Action? - this could be useful for wizard-like forms where each
step of the wizard has a set of fields ; corresponds to a different method
but all of them share the same Action.

I can think of having an expression validator based on currentstep added to
every field short-circuited ; but that's more of a workaround rather than
the right way to do it.

Thanks,
Joseph


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: S2 : Validation per Action method - ideas?

2007-08-09 Thread Zarar Siddiqi
Specify your validation rules in a file called
MyActionClass-myAction-validation.xml where MyActionClass is the
action class and myAction is the name of the action being executed.
So your struts.xml would look something like:

action name=myAction class=MyActionClass method=myMethod.../action

With this setup the validation in
MyActionClass-myAction-validation.xml is mapped to myMethod().

Zarar

On 8/9/07, j alex [EMAIL PROTECTED] wrote:
 Hi,

 Is there a way to declaratively restrict validations depending on the method
 within the Action? - this could be useful for wizard-like forms where each
 step of the wizard has a set of fields ; corresponds to a different method
 but all of them share the same Action.

 I can think of having an expression validator based on currentstep added to
 every field short-circuited ; but that's more of a workaround rather than
 the right way to do it.

 Thanks,
 Joseph


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]