Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 5316 invoked from network); 17 Nov 2005 14:28:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Nov 2005 14:28:08 -0000 Received: (qmail 57346 invoked by uid 500); 17 Nov 2005 14:28:04 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 57280 invoked by uid 500); 17 Nov 2005 14:28:04 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 57269 invoked by uid 99); 17 Nov 2005 14:28:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2005 06:28:03 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [204.29.134.135] (HELO ironprd1.amfam.com) (204.29.134.135) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2005 06:29:37 -0800 Received: from gw2.amfam.com ([10.249.223.20]) by ironprd1.amfam.com with ESMTP; 17 Nov 2005 08:27:42 -0600 X-IronPort-AV: i="3.97,343,1125896400"; d="scan'208,217"; a="366269998:sNHT43129548" Received: from nhq1accoex05vs1.corporate.amfam.com ([10.74.32.81]) by gw2.amfam.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 17 Nov 2005 08:27:41 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [Validator] how to give user input in Arg Date: Thu, 17 Nov 2005 08:27:41 -0600 Message-ID: <2E8B2DCB7DE50B42808F8063C4E2858F074F6129@NHQ1ACCOEX05VS1.corporate.amfam.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [Validator] how to give user input in Arg Thread-Index: AcXrCoBlrIPMdzFaTvSgzen3zmroJAAeEqww From: "Daggumalli, Sivaji" To: "Jakarta Commons Developers List" X-OriginalArrivalTime: 17 Nov 2005 14:27:41.0826 (UTC) FILETIME=[1196B620:01C5EB83] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks Niall for your prompt reply. I appreciate it.=20 Siva -----Original Message----- From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]=20 Sent: Wednesday, November 16, 2005 6:06 PM To: Jakarta Commons Developers List Subject: Re: [Validator] how to give user input in Arg It would be pretty straight forward to do. You need to define some convention to identify that you want a property value in your args, then when you generate the message, replace any such values. For example.... datePatternStrict dd/mm/yyyy Then in your validators (e.g. date validator), when you get the message if the validation fails - then you need to replace any arg values. Something like..... public String getMessage(Object bean, Field field, ValidatorAction va, MessageResources resources) { String validationName =3D va.getName(); // Get the message Msg msg =3D field.getMessage(validationName); if (msg =3D=3D null) { msg =3D va.getMsg(); } // Process args String[] args =3D field.getArgs(validationName); for (int i =3D 0; i < args.length; i++ ) { if (args[i] =3D=3D null) { continue; if (args[i].isResource()) { args[i] =3D resources.getMessage(args[i], null); } else if (args[i].startsWith("${")) { String property =3D args[i].substring(2, args[i].length -2); args[i] =3D ValidatorUtils.getValueAsString(bean, property); } } // retrieve message from resources return resources.getMessage(msg.getKey(), args); } hth Niall ----- Original Message -----=20 From: "Daggumalli, Sivaji" Sent: Wednesday, November 16, 2005 11:25 PM Sorry to confuse you Niall. Actually we are using Commons Validator as standalone project. (Not with Struts). I was wrongly mentioned that earlier by mistake. Is it possible to extend commons Validator 1.2.0 to achieve this behavior? Regards and Thanks in advance. Siva -----Original Message----- From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk] Sent: Wednesday, November 16, 2005 5:14 PM To: Jakarta Commons Developers List Subject: Re: [Validator] how to give user input in Arg There is no way to do this in Struts/Validator currently - unless you write your own versions of the Struts validators and implement a mechanism to do this when generating the error message. Niall ----- Original Message -----=20 From: "Daggumalli, Sivaji" Sent: Wednesday, November 16, 2005 10:04 PM Hi, Afternoon got a commons Validator problem... We are using the Struts Validator and in my validation.xml i have:
datePatternStrict dd/mm/yyyy
In Application Resources i have: errors.date=3D{0} is not a date. x.dateOfBirth=3DDate Of Birth If the user entered date is in the wrong format an error message is produced: Date Of Birth is not a date. This is all good. But what I am trying to achieve is including the input value in the message. I know in the validation.xml you can specify and use vars in the error message (for example): minlength 10 What I want to do is replace the (the literal vaue '10') with the user input. I have tried many things ${field:dateOfBirth}, ${dateOfBirth}, ${myForm.dateOfBirth} but none have worked. Regards and Thanks in advance, Siva --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org