velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wido Hillmann <wido.hillm...@epost.de>
Subject Re: calling setProperty(float) not possible ?
Date Wed, 11 Jul 2001 19:29:20 GMT
Velocity supports only int and string types for setter methods, so you
can only pass is as string and afterwards convert it in your controler.

Wido

Thomas Fahrmeyer wrote:
> 
> 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