Just a quick follow up on the previous message.

> The tags also support the "defaultText" attribute which is used if a value
> passed in is null. This value defaults to "" to avoid "null" appearing in
> JSP.
>
>     <i18n:formatNumber value="<%= n %>" defaultText="not applicable"/>
>

null handling
========

I must say that I wasn't terribly happy about the name of the attribute
"defaultText" - if anyone has any better ideas I'd be glad to change it.
Maybe "ifNull"?

For the number based tags, the value is mandatory.
However for the <formatDate> / <formatTime> / <formatDateTime> tags, if no
value is specified it defaults to "now". If null is specified, then the
defaultText is output. So

    <i18n:formatDate/>

prints the current date using the 'current locale'. The following

    <i18n:formatDate value="<%= null %>" defaultText="N/A">

would display "N/A".


<formatString>
==========

For completeness I've just checked in <formatString> as well. This follows
jonathan's advice about handling null Strings in a similar fashion to the
other formatXXX tags. Again I'd be happy to change the "defaultText"
attribute thats used.

    <i18n:formatString value="<%= null %>" defaultText="N/A">


future enhancements
==============

We might consider adding "id" and "name" attribute support in the
<i18n:locale> tag to allow the lookup of (say) application scope locales via
attribute name or to define scriptlet expressions. Also maybe add lookup by
name of Locale's to the <formatXXX> tags.

Also as per Craig's suggestion, we might want to cache the Format classes
based on a pattern and locale such as DecimalFormat and SimpleDateFormat
instances.


James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to