struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject RE: Moving from bean:write to fmt:formatNumber
Date Tue, 04 May 2004 19:23:46 GMT
Actually, your "application resources" *are* bundles. In other words, you can
use the same property file(s) for Struts and JSTL tags. One thing you can do
for a default JSTL bundle is add the following to web.xml:

<context-param>
  <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
  <param-value>Messages</param-value>
</context-param>

It's sort of the equivalent of the <message-resources> element in
struts-config.xml:

<message-resources parameter="Messages"/>

But, yes, it can get a bit hairy trying to make the two play nicely sometimes
because they really are independent entities.

Quoting Earl Woodman <earl.woodman@verafin.com>:

> Thanks for your response Kris.
> 
> This seems a bit hairy... when I use bean:write, the key comes from my
> application resources file nicely, but with this fmt, I have to use a bundle
> of some sort. Why is this more complicated than the bean:writes? 
>  
> Earl
> 
> -----Original Message-----
> From: Kris Schneider [mailto:kris@dotech.com] 
> Sent: Tuesday, May 04, 2004 3:34 PM
> To: Struts Users Mailing List
> Subject: Re: Moving from bean:write to fmt:formatNumber
> 
> There are (at least) a couple options. One would be to create a property
> like:
> 
> numberFormat={0,number,#.##}
> 
> And then use <fmt:message>:
> 
> <fmt:message key="numberFormat">
>   <fmt:param value="${aNumber}"/>
> </fmt:message>
> 
> Another would be to leverage the fact that the pattern attribute of
> <fmt:formatNumber> accepts an EL expression. So, you'd load the pattern and
> then do:
> 
> <fmt:formatNumber value="${aNumber}" pattern="${numberPattern}"/>
> 
> There are all kinds of ways you could load the pattern, but one would be:
> 
> <fmt:message key="numberPattern" var="numberPattern"/>
> 
> Quoting Earl Woodman <earl.woodman@verafin.com>:
> 
> > Hi,
> > 
> > I'm trying to move from bean:writes to fmt:formatNumber in my 
> > application, but I'm finding that in order to format a number, I can't 
> > get a formatting pattern from my application resources file - there 
> > doesn't seem to be a key parameter in the fmt:formatNumber tag. Has 
> > anyone run into this problem in the past and what have you done about it?
> > 
> > Thanks a lot,
> > Earl
> >  
> >  
> > 
> > Earl Woodman
> > Software Developer
> > Verafin Inc
> > earl.woodman@verafin.com
> 
> --
> Kris Schneider <mailto:kris@dotech.com>
> D.O.Tech       <http://www.dotech.com/>

-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message