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 21:39:58 GMT
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
>
>

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