[ 
https://issues.apache.org/jira/browse/VELOCITY-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Henning Schmiedehausen closed VELOCITY-8.
-----------------------------------------


> issue with simple math operations in template
> ---------------------------------------------
>
>                 Key: VELOCITY-8
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-8
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.1-rc2
>         Environment: Operating System: All
> Platform: PC
>            Reporter: Andriy Rozeluk
>         Assigned To: Velocity-Dev List
>
> Trying to add up a total amount for prices or such things within a template 
> isn't working -- looks like the context variable is resetting itself. I'm 
> using 
> the latest sources from 1.2-dev (20010621)
> Examples (two variations of the same thing, chopped out of my source code):
>       #set( $totalPrice = 0 )
>       #set( $items = ${bundle.getItems()} )
>       #foreach( $i in $items )
>         #set( $totalPrice = $totalPrice + $i.getPrice() )
>       #end
>       <!-- ${totalPrice} -->
>       ##Example 2:
>       #set( $items = ${bundle.getItems()} )
>       #foreach( $i in $items )
>         #if( $totalPrice )
>           #set( $totalPrice = $i.getPrice() + $totalPrice )
>         #else
>           #set( $totalPrice = $i.getPrice() )
>         #end
>         <!-- ${totalPrice} -->
>       #end
> Assume the items in question being looped through (yes, they are displaying 
> properly) all have a price of $7, and there are 4 of them. The price is 
> returned from a Java object which has a public double getPrice() method 
> defined.
> The first example returns:
> <!-- -->
> <!-- -->
> <!-- -->
> <!-- -->
> The second example returns:
> <!-- 7.0 -->
> <!-- 7.0 -->
> <!-- 7.0 -->
> <!-- 7.0 -->
> Obviously, what I wanted was:
> <!-- 7.0 -->
> <!-- 14.0 -->
> <!-- 21.0 -->
> <!-- 28.0 -->
> My velocity.properties:
> resource.loader.1.resource.path = e:\\path\\to\\templates
> file.resource.loader.path = e:\\path\\to\\templates
> file.resource.loader.modificationCheckInterval = 30
> file.resource.loader.cache = true
> velocimacro.permissions.allow.inline = true
> velocimacro.permissions.allow.inline.local.scope = true
> velocimacro.context.localscope = false
> parser.pool.size = 20
> My system is Windows NT 4 running JDK1.3 and I'm using this with Tomcat 3.2.1
> Please don't hesitate to contact me if you need a better example (or help 
> reproducing this problem). Obviously I got the 2 examples because I created 
> the 
> second in an attempt to work around the first one. Thanks for your help!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to