Hello Tim,

I'm not sure why this worked with 1.3.1. If I'm not mistaken, when the
context has Double object in it, the NumberFormat method format(double) is
invoked since with reflection parameters are always passed as objects
instead of primitives and in that case conversion is possible. However, when
the context contains a Float, there is no matching method since the
NumberFormat class has method with signature

StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition
pos) 

and since the two other parameters are missing, Velocity can't find a match.
Velocity does not attempt to convert floats up to doubles since the
conversion produces errors.

http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html

Alternatives:

1. Use the NumberTool provided by Velocity Tools project.
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/NumberTool.html

2. Wrap the NumberFormat class inside your own class that handles Floats
correctly (reinventing the wheel).



Kuntz, Tim wrote:
> 
> I upgraded to Velocity 1.6.2 from 1.3.1 and have run into an issue with
> our existing code/templates. 
> 
> The NumberFormat class has format(double ..), format(long ..), and
> format(Object ..) methods. The format(Object ..) method should be
> invoked but instead is treated as a missing method.
> 

-- 
View this message in context: 
http://old.nabble.com/Reflection-not-handling-Floats-correctly-tp27279916p27285049.html
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to