You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tim Colson <tc...@cisco.com> on 2002/01/06 23:33:47 UTC

[BUG] Struts + Velocity + MathContextTool

Was playing with the Struts part today - happy happy joy joy. :-)


I did however run across some oddities with the parser which doesn't likely
have anything to do with the integration project, but is a bit ugly.

Using the Math ContextTool example, I noticed that the class has method sigs
for int/long/float/double... so I changed the template a bit to play:

<td>\$math.min(345, 765)</td><td>$math.min(345, 765)</td>
OK

<td>\$math.min(345, 765)</td><td>$math.min(345, 765.5)</td>
FAIL
org.apache.velocity.exception.ParseErrorException: Encountered ".5)\r\r\n
\r\r\n            \r\r\n                " at line 45, column 68.
(Curiously - the change is at line 23 column 68, line 45 is end of file. And
of course the CR newlines \r\r\n are showing up in the browser window as
text)

<td>\$math.min(345, foo)</td><td>$math.min(345, 765)</td>
OK - but the output shows the "\" in the label - i.e. \$math.min(345, foo)

<td>\$math.min(345, 765.2)</td><td>$math.min(345, 765)</td>
FAIL -> weird that this is in the LABEL portion.
org.apache.velocity.exception.ParseErrorException: Encountered ".2, foo)" at
line 45, column 35.
Was expecting one of:
    "," ...
    ")" ...
     ...
    org.apache.velocity.exception.ParseErrorException: Encountered ".2,
foo)" at line 45, column 35.
Was expecting one of:
    "," ...
    ")" ...
     ...
Curiously - this error does NOT have \r\r\n. Also, all of the errors create
duplicate output.

Apologies if this has been discussed before... backwater of my brain seems
to recall something similar perhaps, but can't grasp it.

Also - gives me the opportunity to ask if bugs like this should be reported
into the jakarta bugzilla instance for Velocity? I ask because I only see 30
bugs in there.

Timo


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BUG] Struts + Velocity + MathContextTool

Posted by Gabriel Sidler <si...@teamup.ch>.
Tim Colson wrote:
> 
> Was playing with the Struts part today - happy happy joy joy. :-)
> 
> I did however run across some oddities with the parser which doesn't likely
> have anything to do with the integration project, but is a bit ugly.
> 
> Using the Math ContextTool example, I noticed that the class has method sigs
> for int/long/float/double... so I changed the template a bit to play:
> 
> <td>\$math.min(345, 765)</td><td>$math.min(345, 765)</td>
> OK
> 
> <td>\$math.min(345, 765)</td><td>$math.min(345, 765.5)</td>
> FAIL

Tim, thanks for pointing this out. This was oversight when I adapted
the WebMacro MathTool for this example. It will be changed in a next version.

Gabe.






> org.apache.velocity.exception.ParseErrorException: Encountered ".5)\r\r\n
> \r\r\n            \r\r\n                " at line 45, column 68.
> (Curiously - the change is at line 23 column 68, line 45 is end of file. And
> of course the CR newlines \r\r\n are showing up in the browser window as
> text)
> 
> <td>\$math.min(345, foo)</td><td>$math.min(345, 765)</td>
> OK - but the output shows the "\" in the label - i.e. \$math.min(345, foo)
> 
> <td>\$math.min(345, 765.2)</td><td>$math.min(345, 765)</td>
> FAIL -> weird that this is in the LABEL portion.
> org.apache.velocity.exception.ParseErrorException: Encountered ".2, foo)" at
> line 45, column 35.
> Was expecting one of:
>     "," ...
>     ")" ...
>      ...
>     org.apache.velocity.exception.ParseErrorException: Encountered ".2,
> foo)" at line 45, column 35.
> Was expecting one of:
>     "," ...
>     ")" ...
>      ...
> Curiously - this error does NOT have \r\r\n. Also, all of the errors create
> duplicate output.
> 
> Apologies if this has been discussed before... backwater of my brain seems
> to recall something similar perhaps, but can't grasp it.
> 
> Also - gives me the opportunity to ask if bugs like this should be reported
> into the jakarta bugzilla instance for Velocity? I ask because I only see 30
> bugs in there.
> 
> Timo
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [BUG] Struts + Velocity + MathContextTool

Posted by Tim Colson <tc...@cisco.com>.
Asked another way ->

How would I write this plain text in my template without the error?

"Attention Template Designers - do not do this : $math.min(1.5, 2.3) because
it will fail due to floating point numbers. What's a floating point number
and why should you care? That's a different thread. <grin>"

Cheers,
Tim


> -----Original Message-----
> From: Tim Colson [mailto:tcolson@cisco.com]
> Sent: Sunday, January 06, 2002 3:15 PM
> To: Velocity Users List
> Subject: RE: [BUG] Struts + Velocity + MathContextTool
>
>
> Geir -
> > Because the escaping of references is done at runtime, as you
> > can't tell at
> > parsetime what is a reference, as you need  a context to decide that.
>
> uhh...could you run that through the "dumb-it-down" filter and
> tell me again
> why the escaped \$ in the label doesn't appear to be escaped and in fact
> causes an error?
> <td>\$math.min(345, 765.2)</td><td>$math.min(345, 765)</td>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [BUG] Struts + Velocity + MathContextTool

Posted by Tim Colson <tc...@cisco.com>.
Geir -
> Because the escaping of references is done at runtime, as you
> can't tell at
> parsetime what is a reference, as you need  a context to decide that.

uhh...could you run that through the "dumb-it-down" filter and tell me again
why the escaped \$ in the label doesn't appear to be escaped and in fact
causes an error?
<td>\$math.min(345, 765.2)</td><td>$math.min(345, 765)</td>

Thanks,
Tim


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BUG] Struts + Velocity + MathContextTool

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/6/02 5:36 PM, "Tim Colson" <tc...@cisco.com> wrote:

>> Apologies if this has been discussed before... backwater of my brain seems
>> to recall something similar perhaps, but can't grasp it.
> BTW - I do recall the big bunch of Floating point discussion and such... and
> so I pretty much expected the functions to fail in some way, but the weird
> things I noticed were in the escaped labels. ;-)
> Timo
> 

Because the escaping of references is done at runtime, as you can't tell at
parsetime what is a reference, as you need  a context to decide that.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [BUG] Struts + Velocity + MathContextTool

Posted by Tim Colson <tc...@cisco.com>.
> Apologies if this has been discussed before... backwater of my brain seems
> to recall something similar perhaps, but can't grasp it.
BTW - I do recall the big bunch of Floating point discussion and such... and
so I pretty much expected the functions to fail in some way, but the weird
things I noticed were in the escaped labels. ;-)
Timo


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>