Gaet, ActionMessage doesn't support doing that lookup for you automatically, but you can achieve what you want fairly easily:

  Locale locale = request.getLocale();
  String arg = getResources(request).getMessage("label.name");
  errors.add(ActionMessages.GLOBAL_MESSAGE,
    new ActionMessage("error.field.mandatory", arg));

L.

Gaet wrote:
Thanks Martin,

But I want to prepare the error message in the action tag because after, in my JSP, I 
loop over my errors with <html:messages> tag...

I don't know if I'm clear, but if I write the following code :

errors.add(ActionMessages.GLOBAL_MESSAGE, new 
ActionMessage("error.field.mandatory","label.name"));

The result will be "The field label.name is mandatory"

but I would like 'label.name' replaced by its value defined in the resource 
properties....in order to have the result "The field Your Name is mandatory"

Thanks!
----- Original Message ----- From: Martin Gainty To: Struts Users Mailing List Sent: Wednesday, November 30, 2005 4:47 PM
  Subject: Re: Parameter of ActionMessage...


  Bonjour gaet-

the current implementation supports passing in parameters to the bean:message tag at runtime e.g.
  <bean:message key="label.welcome" arg0="Firstname"/>

  which will produce
  The field 'Firstname' is mandatory

  HTH,
  M-
----- Original Message ----- From: "Gaet" <[EMAIL PROTECTED]>
  To: "Struts Users Mailing List" <user@struts.apache.org>
  Sent: Wednesday, November 30, 2005 9:29 AM
  Subject: Re: Parameter of ActionMessage...


  > Nobody knows?
  >
  > Thanks for your time...
  >
> ----- Original Message ----- > From: Gaet
  > To: Mailing List Struts
  > Sent: Wednesday, November 30, 2005 12:14 PM
  > Subject: Parameter of ActionMessage...
  >
  >
  > Hi the list!
  >
> Is it possible to give a key of the ressources.properties in parameter of > an
  > ActionMessage?
  >
  > Example :
  > ----------
  >
  > # In Struts Action file
  >    errors.add(ActionMessages.GLOBAL_MESSAGE, new
  > ActionMessage("error.field.mandatory","label.name"));
  >
  > # In ressources.properties  file
  >    error.field.mandatory = The field '{0}' is mandatory
  >    label.name = Your Name
  >
  > I want the following result :  "The field 'Your Name' is mandatory"
  >
  >
  > Thanks for your help!
  >
  >
  > ---------------------------------------------------------------------
  > 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]
  >
>
  ---------------------------------------------------------------------
  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