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 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]
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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#a12089421
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]

Reply via email to