velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <...@xyris.com>
Subject RE: ArrayList Failure
Date Tue, 13 Feb 2001 21:44:57 GMT
 From: Ivan Saltz [mailto:Ivan@BUC.com]
> [snip]
>
> >Take a look and see what the return type of '$query.cond' is....
>
> Ahh, not being much of a web programmer, I forgot that radio
> buttons with
> value "1" really return a string with value "1". So that
> would explain it.
> Silly me. :-0
>
> This works:
> $condText.get($query.conditionAsInt)
> if I convert to an Integer in the Hashtable $query in my Java code.
>
> It sort of destroys the symmetry of not playing with the form
> data coming in
> with the HttpRequest.getParameter, since I was just stuffing it in the
> Hashmap. So that brings up the following question:
>
> Q1) Is there a way, in the template itself, to do conversions?

No. :)

> For example #set ($i = $query.cond - 1) followed by
> $arr.get($i) doesn't
> work.
> Is there a  math.toInt($query.cond) tool?

No, but you could make one and throw that into your context.  There is
ongoing discussion going on about a context tool set, and that might be a
nice addition, some sort of universal translator.

> Unrelated, but just as valuable to know:
> Q2)
> $query.conditionAsInt is an Integer object
> $arr.get($query.conditionAsInt - 1) fails.
> Are we supposed to be able to embed expressions in parameter lists?

No, that is not in the syntax.

> #set ($i = $query.conditionAsInt - 1) followed by
> $arr.get($i) works in this
> case, but the expression can't be dropped in as a parameter.

That's right.  While it seems strange to us programmers, the philosophy of
the Velocity Template Language (VTL) is 'Keep It Simple' because the
audience is intented to be designers.  That isn't a statement or judgement
about designers or their abilities, but VTL isn't supposed to be a
programming language, and we are doing a decent job of keeping it simple, as
much as it pains some of us :)

thanks

geir





Mime
View raw message