velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Huffstedtler" <rhuffstedt...@ironworks.com>
Subject RE: creating references to arbitrary hashtable
Date Mon, 27 Oct 2008 15:54:54 GMT
It's not yet.  That's the implication I was trying to figure out in the
docs.  It kind of seems like the docs imply that a hashtable would
automatically be instantiated for the identifier.  However, if that's
not the case, am I correct that I just need to instantiate a new
java.util.Hashtable and put it into the context as "slots"?

If that's the case, it raises the next issue that is not immediately
obvious to me from the docs - is there any way by configuration to tell
VelocityLayoutServlet which objects to instantiate and what identifiers
to associate with them, or do I need to subclass the layout servlet and
add it to the context programmatically?

Thanks,
Rob 

-----Original Message-----
From: Peter_Ford@blm.gov [mailto:Peter_Ford@blm.gov] 
Sent: Monday, October 27, 2008 11:34 AM
To: Velocity Users List
Subject: Re: creating references to arbitrary hashtable

If "slots" is a Map object, try:

$slots.get("foo")


"Robert Huffstedtler" <rhuffstedtler@ironworks.com> wrote on 10/27/2008
09:27:26 AM:

> Hi folks -
>
>
>
> I am helping a group migrate some content from Coldfusion to Velocity.
> In their CF code, they have a custom tag which they use in individual
> pages for grouping commonly used page variables into a pseudo-object
> before passing it off to the page wrapper.  The model is very similar
to
> the use of the VelocityLayoutServlet, so that's the direction I'm
going
> for the migration.
>
>
>
> However, trying to set properties on a VTL identifier does not seem to
> work if the identifier does not reference an object.  The
documentation
> does not make it clear that that is a requirement
>
(http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html
> #references).  The description of properties implies that one can
> associate a VTL identifier with a hashtable, but there aren't clear
> directions for doing so.
>
>
>
> Putting this -
>
>
>
> #set ( $slots.foo = "Foo")
>
>
>
> In my index.vm and referencing it like this in my Default.vm:
>
>
>
> $slots.foo<br/>
>
>
>
> Is just resulting in $slots.foo being output as a literal.
>
>
>
> Can someone point me in the right direction here?
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message