You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Manish <pr...@gmx.net> on 2005/01/31 15:02:06 UTC
Adding map to toolbox
Well, I tried to ad a HashMap to a toolbox as well, but none of its methods
(put basically) is working except clear()
This is what I did in tool box-
<tool>
<key>mymap</key>
<scope>application</scope>
<class>java.util.HashMap</class>
</tool>
Then I my velocity code I try this -
$mymap.clear()
$mymap.put("label.name","manish")
$mymap.put("label.country", "India")
but It doesn't work. The template shows me this -
$mymap.put("label.name","manish") $circus.map.put("label.country", "India")
The clear is not shown, so I am assuming that it's getting executed a $mymap
is not NULL.
Any help, pointers???
TIA,
- Manish
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Adding map to toolbox
Posted by Shinobu Kawai Yoshida <sh...@gmail.com>.
Hi Manish,
> I did indeed put quiet notation, just forgot to add it here.
The down side of using Maps like this is that when it has a prior
value, that's going to be printed. (Well, you might want that...) To
make sure nothing gets printed, I sometimes do this:
#set($sink = $map.put('foo', 'bar'))
## I don't like calling state-changing methods from VTL, though...
Best regards,
-- Shinobu
--
Shinobu "Kawai" Yoshida <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Adding map to toolbox
Posted by Manish <pr...@gmx.net>.
I did indeed put quiet notation, just forgot to add it here.
- Manish
----- Original Message -----
From: "Nathan Bubna" <nb...@gmail.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, January 31, 2005 9:21 PM
Subject: Re: Adding map to toolbox
> or you can just use quiet notation:
>
> $!mymap.put('label.name', 'manish')
>
>
> On Mon, 31 Jan 2005 19:58:31 +0530, Manish <pr...@gmx.net> wrote:
> > Never mind, I got it.
> > It was printing it because return value for all these map.put operations
was
> > NULL.
> > call to clear() wasn't printed because it is void.
> > I put this all like this, and it's working now -
> >
> > <!--
> > $mymap.clear()
> > $mymap.put("label.name","manish")
> > $mymap.put("label.country", "India")
> > -->
> >
> > - Manish
> >
> > ----- Original Message -----
> > From: "Manish" <pr...@gmx.net>
> > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > Sent: Monday, January 31, 2005 7:32 PM
> > Subject: Adding map to toolbox
> >
> > > Well, I tried to ad a HashMap to a toolbox as well, but none of its
> > methods
> > > (put basically) is working except clear()
> > >
> > > This is what I did in tool box-
> > >
> > > <tool>
> > > <key>mymap</key>
> > > <scope>application</scope>
> > > <class>java.util.HashMap</class>
> > > </tool>
> > >
> > > Then I my velocity code I try this -
> > >
> > > $mymap.clear()
> > > $mymap.put("label.name","manish")
> > > $mymap.put("label.country", "India")
> > >
> > > but It doesn't work. The template shows me this -
> > >
> > > $mymap.put("label.name","manish") $circus.map.put("label.country",
> > "India")
> > >
> > > The clear is not shown, so I am assuming that it's getting executed a
> > $mymap
> > > is not NULL.
> > > Any help, pointers???
> > >
> > > TIA,
> > > - Manish
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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
Re: Adding map to toolbox
Posted by Nathan Bubna <nb...@gmail.com>.
or you can just use quiet notation:
$!mymap.put('label.name', 'manish')
On Mon, 31 Jan 2005 19:58:31 +0530, Manish <pr...@gmx.net> wrote:
> Never mind, I got it.
> It was printing it because return value for all these map.put operations was
> NULL.
> call to clear() wasn't printed because it is void.
> I put this all like this, and it's working now -
>
> <!--
> $mymap.clear()
> $mymap.put("label.name","manish")
> $mymap.put("label.country", "India")
> -->
>
> - Manish
>
> ----- Original Message -----
> From: "Manish" <pr...@gmx.net>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Monday, January 31, 2005 7:32 PM
> Subject: Adding map to toolbox
>
> > Well, I tried to ad a HashMap to a toolbox as well, but none of its
> methods
> > (put basically) is working except clear()
> >
> > This is what I did in tool box-
> >
> > <tool>
> > <key>mymap</key>
> > <scope>application</scope>
> > <class>java.util.HashMap</class>
> > </tool>
> >
> > Then I my velocity code I try this -
> >
> > $mymap.clear()
> > $mymap.put("label.name","manish")
> > $mymap.put("label.country", "India")
> >
> > but It doesn't work. The template shows me this -
> >
> > $mymap.put("label.name","manish") $circus.map.put("label.country",
> "India")
> >
> > The clear is not shown, so I am assuming that it's getting executed a
> $mymap
> > is not NULL.
> > Any help, pointers???
> >
> > TIA,
> > - Manish
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Adding map to toolbox
Posted by Manish <pr...@gmx.net>.
Never mind, I got it.
It was printing it because return value for all these map.put operations was
NULL.
call to clear() wasn't printed because it is void.
I put this all like this, and it's working now -
<!--
$mymap.clear()
$mymap.put("label.name","manish")
$mymap.put("label.country", "India")
-->
- Manish
----- Original Message -----
From: "Manish" <pr...@gmx.net>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, January 31, 2005 7:32 PM
Subject: Adding map to toolbox
> Well, I tried to ad a HashMap to a toolbox as well, but none of its
methods
> (put basically) is working except clear()
>
> This is what I did in tool box-
>
> <tool>
> <key>mymap</key>
> <scope>application</scope>
> <class>java.util.HashMap</class>
> </tool>
>
> Then I my velocity code I try this -
>
> $mymap.clear()
> $mymap.put("label.name","manish")
> $mymap.put("label.country", "India")
>
> but It doesn't work. The template shows me this -
>
> $mymap.put("label.name","manish") $circus.map.put("label.country",
"India")
>
> The clear is not shown, so I am assuming that it's getting executed a
$mymap
> is not NULL.
> Any help, pointers???
>
> TIA,
> - Manish
>
>
>
> ---------------------------------------------------------------------
> 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