Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 40830 invoked from network); 10 Aug 2007 11:21:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Aug 2007 11:21:40 -0000 Received: (qmail 38747 invoked by uid 500); 10 Aug 2007 11:21:28 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 38716 invoked by uid 500); 10 Aug 2007 11:21:28 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 38705 invoked by uid 99); 10 Aug 2007 11:21:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 04:21:28 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 11:21:24 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1IJSYB-0000nh-Lk for user@struts.apache.org; Fri, 10 Aug 2007 04:21:03 -0700 Message-ID: <12089421.post@talk.nabble.com> Date: Fri, 10 Aug 2007 04:21:03 -0700 (PDT) From: beto To: user@struts.apache.org Subject: RE: S2 : Validation per Action method - ideas? In-Reply-To: <007001c7db3a$4d3edce0$10aa210a@SQLI50624> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: bjorn.tore.wiken@gmail.com References: <006901c7da94$480f84a0$10aa210a@SQLI50624> <12087696.post@talk.nabble.com> <006201c7db2e$0399fb30$10aa210a@SQLI50624> <12088476.post@talk.nabble.com> <007001c7db3a$4d3edce0$10aa210a@SQLI50624> X-Virus-Checked: Checked by ClamAV on apache.org 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: >=20 > Pretty strange indeed. Did you remove all the validation annotations on > the > field setters? >=20 > -----Message d'origine----- > De : beto [mailto:bjorn.tore.wiken@gmail.com]=20 > Envoy=C3=A9 : vendredi 10 ao=C3=BBt 2007 11:56 > =C3=80 : user@struts.apache.org > Objet : RE: S2 : Validation per Action method - ideas? >=20 >=20 > Hi again, and thank you for your answer. >=20 > I've tried using @Validations at the method level as you point out. I'll > try > to illustrate: >=20 > I have an action, not annotated with @Validation, with three action > methods; > input, execute and confirm (custom action method). >=20 > The input method has no annotations and is not validated as expected. >=20 > The execute method is annotated with @Validations: >=20 > @Validations(requiredStrings=3D{ > @RequiredStringValidator(fieldName=3D"amount", > message=3D"Amount is required", key=3D"amount.required") }, regexFields= =3D{ > @RegexFieldValidator(fieldName=3D"amount", expression=3D"^\\d+$", > message=3D"Amount has to be numeric", key=3D"amount.numeric") }) > public String execute() throws Exception { > ... > } >=20 > The confirm method is also annotated with @Validations: >=20 > @Validations(expressions=3D{ @ExpressionValidator(expression=3D"confirm = =3D=3D > true", message=3D"test") }) > public String confirm() throws Exception { > ... > } >=20 > 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. >=20 > What am I doing wrong? >=20 > beto >=20 >=20 > Arno wrote: >>=20 >> 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. >>=20 >> > http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2= /va >> lidator/annotations/Validations.html >>=20 >> -----Message d'origine----- >> De : beto [mailto:bjorn.tore.wiken@gmail.com]=20 >> Envoy=C3=A9 : vendredi 10 ao=C3=BBt 2007 10:57 >> =C3=80 : user@struts.apache.org >> Objet : RE: S2 : Validation per Action method - ideas? >>=20 >>=20 >> Hi. >>=20 >> 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. >>=20 >> Am I missing something? >>=20 >> Do you have the solution Arno? :-)=20 >>=20 >>=20 >> Arno wrote: >>>=20 >>> You should check the Javadoc of the >>> com.opensymphony.xwork2.validator.annotations.Validation annotation. >>>=20 >>> Syntax example: >>>=20 >>> @Validations( >>> requiredFields =3D >>> {@RequiredFieldValidator(type =3D >>> ValidatorType.SIMPLE, >>> fieldName =3D "customfield", message =3D "You must enter a value for >>> field.")}, >>> requiredStrings =3D >>> {@RequiredStringValidator(type =3D >>> ValidatorType.SIMPLE, >>> fieldName =3D "stringisrequired", message =3D "You must enter a value f= or >>> string.")} >>> =20 >>> ) >>> public String execute() throws Exception { >>> return SUCCESS; >>> } >>>=20 >>> -----Message d'origine----- >>> De : j alex [mailto:strutstwouser@gmail.com]=20 >>> Envoy=C3=A9 : jeudi 9 ao=C3=BBt 2007 15:38 >>> =C3=80 : Struts Users Mailing List >>> Objet : S2 : Validation per Action method - ideas? >>>=20 >>> Hi, >>>=20 >>> 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. >>>=20 >>> I can think of having an expression validator based on currentstep adde= d >>> to >>> every field short-circuited ; but that's more of a workaround rather >>> than >>> the right way to do it. >>>=20 >>> Thanks, >>> Joseph >>>=20 >>>=20 >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >>> For additional commands, e-mail: user-help@struts.apache.org >>>=20 >>>=20 >>>=20 >>=20 >> --=20 >> View this message in context: >> > http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242= 670 >> .html#a12087696 >> Sent from the Struts - User mailing list archive at Nabble.com. >>=20 >>=20 >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> For additional commands, e-mail: user-help@struts.apache.org >>=20 >>=20 >>=20 >>=20 >>=20 >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> For additional commands, e-mail: user-help@struts.apache.org >>=20 >>=20 >>=20 >=20 > --=20 > View this message in context: > http://www.nabble.com/S2-%3A-Validation-per-Action-method---ideas--tf4242= 670 > .html#a12088476 > Sent from the Struts - User mailing list archive at Nabble.com. >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org >=20 >=20 >=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org >=20 >=20 >=20 --=20 View this message in context: http://www.nabble.com/S2-%3A-Validation-per-A= ction-method---ideas--tf4242670.html#a12089421 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