Hi all,

Here is the latest incarnation of my formatted output tag and supporting 
classes. Source code, javadocs and tld files are included. BTW, I’ve started 
packaging everything I consider as an extension to Struts under the same 
package names, but starting with org.apache2.xxxxxx.

Comments anybody?

Regards
Ned

>From the docs:

A custom tag (bean2:writeformatted) that allows formatted output from beans. 
A lot of this code has been appropriated from bean:write and bean:message, 
and the usage reflects this. Tag properties scope, name, filter & property 
work just like bean:write and locale & bundle work just like bean:message. 
There are two new tag properties, nullkey and formatkey. Both of these refer 
to strings in the message resource table.

WriteFormatted will work in this way:
·       If the property value is null and nullkey is specified, then this is 
lookup up into the resources and placed in the output stream.

·       If the property value is a string, then this is used as a lookup into the 
resources and placed in the output stream.

·       If the property value is a primitive (int, double, etc) or one of the 
objects based on these types, then value is formatted for output using a 
NumberFormat object, with the format string either being looked up from the 
resources by the formatkey property, or if this property is not specified, 
with the default NumberFormat for this locale. (All NumberFormat's are 
cached inside the FormatInfo object).

·       If the property value implements LocaleFormatted then a FormatInfo object 
is created and passed to the LocaleFormatted.toString(FormatInfo) method and 
the object can decide how to render itself. The formatkey property is passed 
over in the FormatInfo object, but it is up the property value object 
whether it pays any attention to it,

The mechanism for dealing with objects that are not strings or which doesn't 
implement LocaleFormatted is handled by the function getStringForObject. 
This may be overridden in derived classes to provide conversion support for 
legacy or 3rd party objects.

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

writeformatted.zip

Reply via email to