Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 8309 invoked from network); 4 Dec 2009 15:05:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Dec 2009 15:05:14 -0000 Received: (qmail 58303 invoked by uid 500); 4 Dec 2009 15:05:11 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 58241 invoked by uid 500); 4 Dec 2009 15:05:11 -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 58228 invoked by uid 99); 4 Dec 2009 15:05:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Dec 2009 15:05:11 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of greg.lindholm@gmail.com designates 209.85.219.222 as permitted sender) Received: from [209.85.219.222] (HELO mail-ew0-f222.google.com) (209.85.219.222) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Dec 2009 15:05:09 +0000 Received: by ewy22 with SMTP id 22so2868568ewy.39 for ; Fri, 04 Dec 2009 07:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=iXp6VxmxtVfj0yCOLYwMYQCmoNvc1qFCRZdOQIEhheM=; b=EAXJ6ETO/dL2id0iBx+Z5nqLbZj4aOR0pXKfOCtxbEIkacoFApku+1lGMmuupbZXY5 9rruZpJhvZ3QV4LLvvhqlJa5YCnE6vRDsNaHCpRON+E05xB2k32fcgJFX6aQ06UAC1TR GsgqS6SeQ4jnPbDw+yHbjWyr4dUFVBi9mo11E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=ncFhFN2LE2Vi+3UxwDZxIdRT6kGgXpDRrgTspWam5U/5tD+gHHzIVJUESSTrGZJ9/K 022G7oR89hV+1FVlkjHvPx3L15Kd57eKtlan4w97z6nD2doBcX8Ma6cmkGFQyONbBP64 aQ0DG2fDq8D5zTWMZ2E3DU86P2ovXgJ7mwoCU= MIME-Version: 1.0 Received: by 10.213.0.139 with SMTP id 11mr3247644ebb.86.1259939087268; Fri, 04 Dec 2009 07:04:47 -0800 (PST) In-Reply-To: <8141dfcc0912040225n2abfb1d6h435533b154d15bfa@mail.gmail.com> References: <8141dfcc0912040225n2abfb1d6h435533b154d15bfa@mail.gmail.com> Date: Fri, 4 Dec 2009 10:04:47 -0500 Message-ID: <74a2042d0912040704i1e4e6583g3ab00c87de8ef88b@mail.gmail.com> Subject: Re: RequiredFieldValidator and error message from property file via key From: Greg Lindholm To: Struts Users Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable You may have a different problem then you think; The @RequiredFieldValidator does not make any sense on a int (primitive) field as an int cannot be null. The validation interceptor checks the values on the fields after params interceptor sets the fields. The RequiredFieldValidator checks if the field is null which will never be the case for a primitive field. On Fri, Dec 4, 2009 at 5:25 AM, Per Johansson wrote: > Hi, > > I'm trying to get error messages from a resource bundle. > > This is the code for my action class: > > @RequiredFieldValidator(type=3DValidatorType.FIELD, > key=3D"myFieldErrorMsg", message=3D"Error!!!!") > public void setMyField(int myField) { > =A0 =A0this.myField =3D myField; > } > > @Override > public void validate() { > =A0 =A0if (!isMyFieldValid(myField)) { > =A0 =A0 =A0 =A0addFieldError("myField", getText("myFieldErrorMsg")); > =A0 =A0} > } > > When validation fails for setMyField I don't get the expected error > message from my resource bundle. > Instead I get a struts default error message "Invalid field value for fie= ld ..." > > But when i call getText from the validate method, I get the expected > error message. > > How can I get a message from a resource bundle using the annotation > based validator? > I'm using weblogic 10.0. > > > /Best regards, Per Johansson > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org