struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: message masks
Date Sat, 07 Jul 2001 20:58:33 GMT


On Fri, 6 Jul 2001, Renzo Toma wrote:

> 
> Hi there,
> 
> First of all, I want to thank all Struts developers & contributors for
> creating such a nifty  framework. After working with it for some time now, I
> really miss message masks, like 'Hi {0}, welcome back'. Ok, I _could_ use a
> pre and suffix, but that's not very proper.
> 

You can use the "arg0" through "arg4" attributes of <bean:message> to
accomplish this today.  For example, assume that you have a message in
your application resources named "text.welcome" that has the text value

  Hi {0}, welcome back

Now, also assume you've got a session attribute named "user" that was
placed there by your login processing, and assume that it has a firstName
property with the user's name.  To accomplish what you want:

  ...
  <jsp:useBean id="user" scope="session" type="....."/>
  ...
  <bean:message key="text.welcome"
   arg0="<%= user.getFirstName() %>"/>
  ...

> Now I have found a thread (url below) on the user mailinglist, but I cant
> seem to find any resolution on the subject.
> 
> http://marc.theaimsgroup.com/?l=struts-user&m=99400475317567&w=2
> 
> So I hope you can answer my question. Do you know by any chance if someone's
> working on it, or should I consider this a do-it-yourself?
> 

It is technically feasible to make the <bean:message> tag support nested
tags to create the argument values, as presented in this mailing list
message.  However, this would have some negative effect on performance
(and code size of the generated page) because the underlying Java class
would have to implement BodyTag instead of Tag (in the JSP
APIs).  Therefore, I'd prefer that we don't make that particular change.

> 
> 
> Cheers,
> 
> Renzo
> 
> 

Craig



Mime
View raw message