velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rian Schmidt <r...@finebrand.com>
Subject Re: calling setProperty(float) not possible ?
Date Wed, 11 Jul 2001 16:46:33 GMT
No idea here, but since I always have to read dumb suggestions, I thought
I'd make one without trying it first...

Did you try something like:
$person.setIncome(5000.00)
- or -
$person.setIncome((float)5000)

The other thing I'd consider would be to put a utility in the context (or
method itself) to allow different types of arguments and convert them
depending on their type.

Rian
----- Original Message -----
From: Thomas Fahrmeyer <thomas.fahrmeyer@einsurance.de>
To: Velocity-User <velocity-user@jakarta.apache.org>
Sent: Wednesday, July 11, 2001 8:02 AM
Subject: calling setProperty(float) not possible ?


> Hi,
>
> I have an object called "person" with method "setIncome(float income)"
> accessible within the template:
> ...
> $person.setIncome(5000)
> ...
>
> while merging the template Vel don't calls setIncome, because the 5000 is
> interpreted as an int and a method with that signature doesnt exist. Okay,
> but if I try
> $person.setIncome(5000f)
>
> to force to interpret the argument as float - Velocity comes up with an
> error:
> Wed Jul 11 16:53:54 GMT+02:00 2001  [error] Parser Exception: list.htm :
> org.apache.velocity.runtime.parser.ParseException: Encountered "f" at line
> 35, column 31.
> Was expecting one of:
>     "," ...
>     ")" ...
>     <WHITESPACE> ...
>
> at org.apache.velocity.runtime.parser.Parser.process(Parser.java:190)
> at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:78)
> at org.apache.velocity.runtime.Runtime.parse(Runtime.java:620)
> at org.apache.velocity.Template.process(Template.java:159)
> at
>
org.apache.velocity.runtime.resource.ResourceManager.getResource(ResourceMan
> ager.java:336)
> at org.apache.velocity.runtime.Runtime.getTemplate(Runtime.java:667)
> at
>
org.apache.velocity.servlet.VelocityServlet.getTemplate(VelocityServlet.java
> :489)
> at
>
de.einsurance.gui.framework.AbstractScreen.handleRequest(AbstractScreen.java
> :171)
> at
>
de.einsurance.gui.framework.TemplateScreen.handleRequest(TemplateScreen.java
> :52)
> at
>
org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:3
> 26)
> ...
>
> How can I handle methods needing floats, doubles or other datatypes as
> arguments ?? I would not be easy to used Float or Double Objects (if that
> would be the solution) ;( Here generated objects are used.
>
> Thanx.
> Thomas
>


Mime
View raw message