velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claude Brisson" <cla...@savoirweb.com>
Subject Re: Indirect references
Date Fri, 08 Aug 2003 19:29:29 GMT
This has been discussed not long ago, see http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg10305.html

In a nutshell, "$$" is not implemented, some folks (including me) think it should, others
think it should not... and the most common
workaround is to explicitely call generic getters from the VTL.

For your example, you need to place a reference to the context inside itself with :

[java] context.put("context",context)

and then do :

[VTL] #set($list = $context.get("$listname"))

CloD

----- Original Message -----
From: "Ted Husted" <husted@apache.org>
To: <velocity-user@jakarta.apache.org>
Sent: vendredi 8 août 2003 20:11
Subject: Indirect references


> This may sound odd, but, if it were possible, I'd like to do a bit of
> indirection in my variable references.
>
> The use case is this: I have a list in the context. The list may end up
> under one name or another, but I do know what the list's name is before
> I forward to the template. I'd like the template to set a local variable
> to the list based on the name that I pass inside of another variable.
>
> Essentially, something like this:
>
> #set($list = ${$listname})
>
> where I've already something like has already been done (in one place or
> another):
>
> .set("someName",list);
>
> ... later ...
>
> .set("listname","someName");
>
> and have $list be a pointer to list in the first statement.
>
> Possible?
>
> -Ted.
>
>
> --
> Ted Husted,
>    Junit in Action  - <http://www.manning.com/massol/>,
>    Struts in Action - <http://husted.com/struts/book.html>,
>    JSP Site Design  - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>


Mime
View raw message