velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jian chen" <chenjian1...@gmail.com>
Subject Re: clarification needed for getting HashMap values in the templates
Date Fri, 07 Jul 2006 22:01:15 GMT
Thanks!

I was testing and did find from my experiment that getBar() has higher
precedence than get("Bar").

If this is not already in the Velocity user guide or developer guide, maybe
the guide could be enhanced with this info? This way, it would definitely
clear out some user confusion.

Jian

On 7/7/06, Nathan Bubna <nbubna@gmail.com> wrote:
>
> from a look at the default Uberspect for version 1.4
> (
> http://svn.apache.org/repos/asf/jakarta/velocity/engine/tags/VEL_1_4/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
> ),
> it would appear that the order of lookup for $foo.bar is:
>
> getbar()
> getBar()
> get("bar")
> isBar()
>
> On 7/7/06, jian chen <chenjian1227@gmail.com> wrote:
> > Cool, thanks! Now I look at the Velocity user guide and find this:
> >
> > *"$customer.Address*. It can have two meanings. It can mean, Look in the
> > hashtable identified as *customer* and return the value associated with
> the
> > key *Address*. But *$customer.Address* can also be referring to a method
> > (references that refer to methods will be discussed in the next
> section); *
> > $customer.Address* could be an abbreviated way of writing *
> > $customer.getAddress()*."
> >
> > so, one more question, if I have both the get(String s) and the
> getAddress()
> > methods for the Customer object. In the template, I have
> $customer.Address,
> > Which method would take precedence? customer.get("address") or
> > customer.getAddress()?
> >
> > Jian
> >
> > On 7/7/06, Will Glass-Husain <wglass@forio.com> wrote:
> > >
> > > yes.
> > >
> > > WILL
> > >
> > > jian chen wrote:
> > > > Hi, All,
> > > >
> > > > As a long term Velocity user, I think I have been pretty savvy for
> > > > Velocity
> > > > usage. Still got a question to ask though.
> > > >
> > > > If I put a HashMap in the Velocity template,
> > > >
> > > > HashMap map = new HashMap();
> > > > map.put("aKey", "aValue");
> > > > ctx.put("map", map);
> > > >
> > > > I can retrieve the value in the template by: $map.aKey.
> > > >
> > > > I tried to find relevant info. in Velocity user guide, but couldn't
> > > > find any
> > > > relating this usage.
> > > >
> > > > So, is it that $map.aKey is the same as $map.get("aKey")?
> > > >
> > > > Thanks,
> > > >
> > > > Jian
> > > >
> > >
> > > --
> > > Forio Business Simulations
> > >
> > > Will Glass-Husain
> > > phone (415) 440-7500 x89
> > > mobile (415) 235-4293
> > > wglass@forio.com
> > > www.forio.com
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message