tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Luehe <Jan.Lu...@Sun.COM>
Subject Re: I18N <messageArg> tag
Date Tue, 18 Dec 2001 17:59:39 GMT
Cindy:


> I'm trying to figure out <messageArg> tag.  The specs say, "If the message 
> corresponding to the given key is compound, that is, contains one or more 
> variables, it can be supplied with argument values for these variables by 
> using a <messageArg> subtag for each argument value"
> 
> The example in the specs:
> 
>     <fmt:message key="Welcome">
>       <fmt:messageArg value="$dateArg"/>
>     </fmt:message>
> 
> Does this mean that the 'Welcome' key contains more than one value?  Is the 
> <messageArg> tag printing a date that is grabbed from the resource bundle?

In the above example, the message key "Welcome" could have been mapped
to a message of the following form:

  Welcome! Today's date: {0}

which would have been looked up in the appropriate resource bundle.

"{0}" is a placeholder that gets replaced with the argument value
supplied by the <messageArg> action, in this case, the date
stored in the scoped attribute named "dateArg".

> Welcome = "welcome"
> Welcome.dateArg = "Monday, January 2nd, 2002"
> 
> But, it's not because the '$dateArg' is a scoped variable.

No. Another way of achieving the same result would have been:

  <fmt:message key="Welcome">
   <fmt:messageArg>
    <fmt:formatDate/>
   </fmt:messageArg>
  </fmt:message>

> So, why bother with the messageArg tag?

There's a good tutorial section on formatting compound messages at

  http://java.sun.com/docs/books/tutorial/i18n/format/messageintro.html

Let me know if that still leaves any questions you might have open.


Jan



--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message