You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Kevin Baynes <kb...@seagullsw.com> on 2002/01/31 23:31:06 UTC

VelocityContext.putall()?

In my Web application, I have a number of methods that return HashMaps of
key/value pairs that I then place into the VelocityContext and do
Template.merge().

I noticed the syntax VelocityContext.put() is like that of HashMap, and
indeed (upon inspection) VelocityContext uses a HashMap internally for
storage of values passed into VelocityContext.put().

I intuitively sort of expected to be able to do a
VelocityContext.putall(Map), instead of having to iterate over my HashMap
and call VelocityContext.put() casting the keys to String as I go.

Does anybody else think that VelocityContext.putall(Map) would be usefull?
or is my use of it out of the ordinary?

--
Kevin Baynes


PS-

VelocityContext.putall would be defined in the Context interface (with put),
so the subclasses would have to implement it. hassle?

Also, I see that AbstractContext.put() and VelocityContext.internalPut()
enforce that the key is a String. At some point the rendering engine has to
pull out the key from HashMap and cast it to String, right? You could get a
ClassCastException... trust the programmer or not?





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: VelocityContext.putall()?

Posted by Normand Gagnon <ng...@newtradetech.com>.
I agree with you, in my webapplication I use a kind of cache of context 
which represent a bunch of tools. So, depending on the requested URL, I get 
from the cacheMap the correct toolset, but then I have to iterate in the 
map to retrieve each tools and put each of them in the VelocityContext, a 
putall(Map) method would be more "elegant".

At 05:31 PM 1/31/2002 -0500, you wrote:

>In my Web application, I have a number of methods that return HashMaps of
>key/value pairs that I then place into the VelocityContext and do
>Template.merge().
>
>I noticed the syntax VelocityContext.put() is like that of HashMap, and
>indeed (upon inspection) VelocityContext uses a HashMap internally for
>storage of values passed into VelocityContext.put().
>
>I intuitively sort of expected to be able to do a
>VelocityContext.putall(Map), instead of having to iterate over my HashMap
>and call VelocityContext.put() casting the keys to String as I go.
>
>Does anybody else think that VelocityContext.putall(Map) would be usefull?
>or is my use of it out of the ordinary?
>
>--
>Kevin Baynes
>
>
>PS-
>
>VelocityContext.putall would be defined in the Context interface (with put),
>so the subclasses would have to implement it. hassle?
>
>Also, I see that AbstractContext.put() and VelocityContext.internalPut()
>enforce that the key is a String. At some point the rendering engine has to
>pull out the key from HashMap and cast it to String, right? You could get a
>ClassCastException... trust the programmer or not?
>
>
>
>
>
>--
>To unsubscribe, 
>e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: 
><ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: VelocityContext.putall()?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 2/11/02 4:20 AM, "Kelvin Tan" <ke...@relevanz.com> wrote:

> 
> ----- Original Message -----
> From: Kevin Baynes <kb...@seagullsw.com>
> To: Velocity Users List <ve...@jakarta.apache.org>
> Sent: Monday, February 04, 2002 11:59 PM
> Subject: RE: VelocityContext.putall()?
> 
> 
> [snip]
>> BTW -
>> 
>> I was looking at the source code when I said I couldn't find the
>> constructor, I looked at VelocityContext and it's superclass
> AbstractContext
>> and couldn't find it. Here are the version ids:
>> @version $Id: VelocityContext.java,v 1.4 2001/03/19 22:32:49 geirm Exp $
>> @version $Id: AbstractContext.java,v 1.7 2001/08/30 20:58:27 dlr Exp $
>> 
>> I have Velocity-1.2. Could something be out of sync?
>> 
>> 
> 
> Glanced through the javadocs and source of Velocity-1.2 and couldn't find
> the constructor (which accepts a Map as argurment) Geir was talking about
> either...
> 
> Is it in Velocity-1.2 or a more recent CVS build?

It's 1.3-dev.  Current CVS HEAD.


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
The question is : What is a Mahnamahna?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: VelocityContext.putall()?

Posted by Kelvin Tan <ke...@relevanz.com>.
----- Original Message -----
From: Kevin Baynes <kb...@seagullsw.com>
To: Velocity Users List <ve...@jakarta.apache.org>
Sent: Monday, February 04, 2002 11:59 PM
Subject: RE: VelocityContext.putall()?


[snip]
> BTW -
>
> I was looking at the source code when I said I couldn't find the
> constructor, I looked at VelocityContext and it's superclass
AbstractContext
> and couldn't find it. Here are the version ids:
> @version $Id: VelocityContext.java,v 1.4 2001/03/19 22:32:49 geirm Exp $
> @version $Id: AbstractContext.java,v 1.7 2001/08/30 20:58:27 dlr Exp $
>
> I have Velocity-1.2. Could something be out of sync?
>
>

Glanced through the javadocs and source of Velocity-1.2 and couldn't find
the constructor (which accepts a Map as argurment) Geir was talking about
either...

Is it in Velocity-1.2 or a more recent CVS build?

Regards,
Kelvin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: VelocityContext.putall()?

Posted by Kevin Baynes <kb...@seagullsw.com>.
Thanks.

The more I thought about adding VelocityContext.putAll(Map), I eventually
came to the conclusion that it is just as easy to do
"VelocityContext.put("myMap",Map)" . I could then access the memebers using
dot notation ($myMap.loginid, etc.) [ if I felt strongly about doing the
iteration, but I don't :) ]

I think that VC.putAll(Map) would be elegant, but the reflection engine
pretty much obviates the need for it.

-Kevin


BTW -

I was looking at the source code when I said I couldn't find the
constructor, I looked at VelocityContext and it's superclass AbstractContext
and couldn't find it. Here are the version ids:
@version $Id: VelocityContext.java,v 1.4 2001/03/19 22:32:49 geirm Exp $
@version $Id: AbstractContext.java,v 1.7 2001/08/30 20:58:27 dlr Exp $

I have Velocity-1.2. Could something be out of sync?



> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Friday, February 01, 2002 2:50 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: VelocityContext.putall()?
>
>
> On 2/1/02 11:51 AM, "Kevin Baynes" <kb...@seagullsw.com> wrote:
>
> >
> > Thanks for the response. :-)
> >
> > Sounds like your solution would work for me...
> >
> > I've looked for a constructor in VelocityContext.java that
> takes a Map for
> > storage, but cannot find it. I only found VelocityContext() and
> > VelocityContext(Context innerConext). I have velocity-1.2.
> >
> > Can you give me a more explicit instruction?
>
> My bad. The docs on the website are not up-to-date (they are 1.1, and not
> 1.2) and this is a 1.2 feature that daniel put in.
>
> Just generate the docs for yourself, or look at the class.  It will be
> clear.
>
> For a hint :
>
> VelocityContext new = VelocityContext( myMap );
>
> :)
>
> >
> > Tx!
> >
> > -k
> >
> >
> >> -----Original Message-----
> >> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> >> Sent: Thursday, January 31, 2002 6:27 PM
> >> To: velocity-user@jakarta.apache.org
> >> Subject: Re: VelocityContext.putall()?
> >>
> >>
> >> On 1/31/02 5:31 PM, "Kevin Baynes" <kb...@seagullsw.com> wrote:
> >>
> >>>
> >>> In my Web application, I have a number of methods that return
> >> HashMaps of
> >>> key/value pairs that I then place into the VelocityContext and do
> >>> Template.merge().
> >>>
> >>> I noticed the syntax VelocityContext.put() is like that of
> HashMap, and
> >>> indeed (upon inspection) VelocityContext uses a HashMap internally for
> >>> storage of values passed into VelocityContext.put().
> >>>
> >>> I intuitively sort of expected to be able to do a
> >>> VelocityContext.putall(Map), instead of having to iterate over
> >> my HashMap
> >>> and call VelocityContext.put() casting the keys to String as I go.
> >>>
> >>> Does anybody else think that VelocityContext.putall(Map) would
> >> be usefull?
> >>> or is my use of it out of the ordinary?
> >>
> >> It's already there... There's a CTOR for VelocityContext that
> takes a Map,
> >> and actually uses that as the internal storage....
> >>
> >> That's a little different than a putAll(), but gets you most
> of the way :)
> >>
> >>>
> >>> --
> >>> Kevin Baynes
> >>>
> >>>
> >>> PS-
> >>>
> >>> VelocityContext.putall would be defined in the Context
> >> interface (with put),
> >>> so the subclasses would have to implement it. hassle?
> >>
> >> Yes - it doesn't make much sense to put on the Context inteface,
> >> I think...
> >>
> >>>
> >>> Also, I see that AbstractContext.put() and
> VelocityContext.internalPut()
> >>> enforce that the key is a String. At some point the rendering
> >> engine has to
> >>> pull out the key from HashMap and cast it to String, right?
> >>
> >> Not sure if that's the right way to think about it -
> generally, it looks
> >> into the HashMap with a String key when there's a reference
> that needs it.
> >>
> >> However, it is possible, I would imagine.
> >>
> >>
> >>> You could get a
> >>> ClassCastException... trust the programmer or not?
> >>
> >>
> >> --
> >> Geir Magnusson Jr.
> >> geirm@optonline.net
> >> System and Software Consulting
> >> "Whoever would overthrow the liberty of a nation must begin by
> >> subduing the
> >> freeness of speech." - Benjamin Franklin
> >>
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> POC lives!
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: VelocityContext.putall()?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 2/1/02 11:51 AM, "Kevin Baynes" <kb...@seagullsw.com> wrote:

> 
> Thanks for the response. :-)
> 
> Sounds like your solution would work for me...
> 
> I've looked for a constructor in VelocityContext.java that takes a Map for
> storage, but cannot find it. I only found VelocityContext() and
> VelocityContext(Context innerConext). I have velocity-1.2.
> 
> Can you give me a more explicit instruction?

My bad. The docs on the website are not up-to-date (they are 1.1, and not
1.2) and this is a 1.2 feature that daniel put in.

Just generate the docs for yourself, or look at the class.  It will be
clear.

For a hint :

VelocityContext new = VelocityContext( myMap );

:)

> 
> Tx!
> 
> -k
> 
> 
>> -----Original Message-----
>> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
>> Sent: Thursday, January 31, 2002 6:27 PM
>> To: velocity-user@jakarta.apache.org
>> Subject: Re: VelocityContext.putall()?
>> 
>> 
>> On 1/31/02 5:31 PM, "Kevin Baynes" <kb...@seagullsw.com> wrote:
>> 
>>> 
>>> In my Web application, I have a number of methods that return
>> HashMaps of
>>> key/value pairs that I then place into the VelocityContext and do
>>> Template.merge().
>>> 
>>> I noticed the syntax VelocityContext.put() is like that of HashMap, and
>>> indeed (upon inspection) VelocityContext uses a HashMap internally for
>>> storage of values passed into VelocityContext.put().
>>> 
>>> I intuitively sort of expected to be able to do a
>>> VelocityContext.putall(Map), instead of having to iterate over
>> my HashMap
>>> and call VelocityContext.put() casting the keys to String as I go.
>>> 
>>> Does anybody else think that VelocityContext.putall(Map) would
>> be usefull?
>>> or is my use of it out of the ordinary?
>> 
>> It's already there... There's a CTOR for VelocityContext that takes a Map,
>> and actually uses that as the internal storage....
>> 
>> That's a little different than a putAll(), but gets you most of the way :)
>> 
>>> 
>>> --
>>> Kevin Baynes
>>> 
>>> 
>>> PS-
>>> 
>>> VelocityContext.putall would be defined in the Context
>> interface (with put),
>>> so the subclasses would have to implement it. hassle?
>> 
>> Yes - it doesn't make much sense to put on the Context inteface,
>> I think...
>> 
>>> 
>>> Also, I see that AbstractContext.put() and VelocityContext.internalPut()
>>> enforce that the key is a String. At some point the rendering
>> engine has to
>>> pull out the key from HashMap and cast it to String, right?
>> 
>> Not sure if that's the right way to think about it - generally, it looks
>> into the HashMap with a String key when there's a reference that needs it.
>> 
>> However, it is possible, I would imagine.
>> 
>> 
>>> You could get a
>>> ClassCastException... trust the programmer or not?
>> 
>> 
>> --
>> Geir Magnusson Jr.
>> geirm@optonline.net
>> System and Software Consulting
>> "Whoever would overthrow the liberty of a nation must begin by
>> subduing the
>> freeness of speech." - Benjamin Franklin
>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
POC lives!


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: VelocityContext.putall()?

Posted by Kevin Baynes <kb...@seagullsw.com>.
Thanks for the response. :-)

Sounds like your solution would work for me...

I've looked for a constructor in VelocityContext.java that takes a Map for
storage, but cannot find it. I only found VelocityContext() and
VelocityContext(Context innerConext). I have velocity-1.2.

Can you give me a more explicit instruction?

Tx!

-k


> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Thursday, January 31, 2002 6:27 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: VelocityContext.putall()?
>
>
> On 1/31/02 5:31 PM, "Kevin Baynes" <kb...@seagullsw.com> wrote:
>
> >
> > In my Web application, I have a number of methods that return
> HashMaps of
> > key/value pairs that I then place into the VelocityContext and do
> > Template.merge().
> >
> > I noticed the syntax VelocityContext.put() is like that of HashMap, and
> > indeed (upon inspection) VelocityContext uses a HashMap internally for
> > storage of values passed into VelocityContext.put().
> >
> > I intuitively sort of expected to be able to do a
> > VelocityContext.putall(Map), instead of having to iterate over
> my HashMap
> > and call VelocityContext.put() casting the keys to String as I go.
> >
> > Does anybody else think that VelocityContext.putall(Map) would
> be usefull?
> > or is my use of it out of the ordinary?
>
> It's already there... There's a CTOR for VelocityContext that takes a Map,
> and actually uses that as the internal storage....
>
> That's a little different than a putAll(), but gets you most of the way :)
>
> >
> > --
> > Kevin Baynes
> >
> >
> > PS-
> >
> > VelocityContext.putall would be defined in the Context
> interface (with put),
> > so the subclasses would have to implement it. hassle?
>
> Yes - it doesn't make much sense to put on the Context inteface,
> I think...
>
> >
> > Also, I see that AbstractContext.put() and VelocityContext.internalPut()
> > enforce that the key is a String. At some point the rendering
> engine has to
> > pull out the key from HashMap and cast it to String, right?
>
> Not sure if that's the right way to think about it - generally, it looks
> into the HashMap with a String key when there's a reference that needs it.
>
> However, it is possible, I would imagine.
>
>
> > You could get a
> > ClassCastException... trust the programmer or not?
>
>
> --
> Geir Magnusson Jr.
> geirm@optonline.net
> System and Software Consulting
> "Whoever would overthrow the liberty of a nation must begin by
> subduing the
> freeness of speech." - Benjamin Franklin
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to pass values dvsl->java?????

Posted by Brad Cox <bc...@virtualschool.edu>.
Nevermind, Geir. Found it. The methods were public but the class 
was not. Sorry.

On Friday, February 1, 2002, at 02:48 PM, Geir Magnusson Jr. wrote:

> Are your methods public?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to pass values dvsl->java?????

Posted by Brad Cox <bc...@virtualschool.edu>.
On Friday, February 1, 2002, at 02:48 PM, Geir Magnusson Jr. wrote:

> Are your methods public?

Absolutely.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to pass values dvsl->java?????

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Are your methods public?


On 2/1/02 1:17 PM, "Brad Cox" <bc...@virtualschool.edu> wrote:

> Geir, while waiting for your response I've tried passing an
> object to dvsl in the context  with a method (addPage(String
> name, String value)) to save stuff as side effects.
> 
> However the method isn't being recognized. In fact, none of my
> methods are recognized, just (presumably) those my class
> inherits from Object like getClass and toString().
> 
> Here's the input. $cache is the object passed in the context.
> The fake(), fake1(), fake2() are methods I've added to help
> diagnose the problem, and addPage() is the real method.
> 
> <pre>
> $cache
> $cache.getClass()
> $cache.toString()
> $cache.fake()
> $cache.fake1("foo")
> $cache.fake2("foo", "bar")
> $cache.addPage("foo", "bar")
> $cache.addPage($attrib.ident.toString(), $node.copy().toString())
> $cache.addPage($ident, $text)
> </pre>
> 
> Here's the output. Note that getClass() and toString() are
> recognized, but none of my class-specific methods.
> 
> <pre>
> edu.virtualschool.jcms.model.Task$PageCache@d115496
> class edu.virtualschool.jcms.model.Task$PageCache
> edu.virtualschool.jcms.model.Task$PageCache@d115496
> $cache.fake()
> $cache.fake1("foo")
> $cache.fake2("foo", "bar")
> $cache.addPage("foo", "bar")
> $cache.addPage($attrib.ident.toString(), $node.copy().toString())
> $cache.addPage($ident, $text)
> </pre>
> 
> Roach motel. Data goes in but never come out. ;)
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"The J2EE Compatible brand has achieved significant momentum over the past
two years, and we want to make sure that any open source efforts don't
impact the viability of that effort. "
- Karen Tegan, Director of J2EE Compatibility and Platform Services
 Sun Microsystems


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


How to pass values dvsl->java?????

Posted by Brad Cox <bc...@virtualschool.edu>.
Geir, while waiting for your response I've tried passing an 
object to dvsl in the context  with a method (addPage(String 
name, String value)) to save stuff as side effects.

However the method isn't being recognized. In fact, none of my 
methods are recognized, just (presumably) those my class 
inherits from Object like getClass and toString().

Here's the input. $cache is the object passed in the context. 
The fake(), fake1(), fake2() are methods I've added to help 
diagnose the problem, and addPage() is the real method.

<pre>
$cache
$cache.getClass()
$cache.toString()
$cache.fake()
$cache.fake1("foo")
$cache.fake2("foo", "bar")
$cache.addPage("foo", "bar")
$cache.addPage($attrib.ident.toString(), $node.copy().toString())
$cache.addPage($ident, $text)
</pre>

Here's the output. Note that getClass() and toString() are 
recognized, but none of my class-specific methods.

<pre>
edu.virtualschool.jcms.model.Task$PageCache@d115496
class edu.virtualschool.jcms.model.Task$PageCache
edu.virtualschool.jcms.model.Task$PageCache@d115496
$cache.fake()
$cache.fake1("foo")
$cache.fake2("foo", "bar")
$cache.addPage("foo", "bar")
$cache.addPage($attrib.ident.toString(), $node.copy().toString())
$cache.addPage($ident, $text)
</pre>

Roach motel. Data goes in but never come out. ;)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: DVSL returns values in the context??

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/31/02 9:37 PM, "Brad Cox" <bc...@virtualschool.edu> wrote:

> Geir, I thought
> 
> #set($foo = $something)
> 
> in a dvsl script would store $foo in the incoming context. I was
> hoping to retrieve
> values on return as
> 
> Object foo = context.get("foo");
> 
> Apparently not; foo is null. What am I missing?
> 

Well, 'foo', apparently.

(I crack myself up...)

The whole DVSL context thing is a little complicated.  Not hard, just not
simple.

So what's happening is that I need to change it so that any 'puts' go into
the 'user context'.

There was some reasoning for the way it is, but I can't remember now. I'll
try and recall - if nothing but fuzzy thinking on my part, I'll fix....


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"We will be judged not by the monuments we build, but by the monuments we
destroy" - Ada Louise Huxtable


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


DVSL returns values in the context??

Posted by Brad Cox <bc...@virtualschool.edu>.
Geir, I thought

	#set($foo = $something)

in a dvsl script would store $foo in the incoming context. I was 
hoping to retrieve
values on return as

	Object foo = context.get("foo");

Apparently not; foo is null. What am I missing?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: VelocityContext.putall()?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/31/02 5:31 PM, "Kevin Baynes" <kb...@seagullsw.com> wrote:

> 
> In my Web application, I have a number of methods that return HashMaps of
> key/value pairs that I then place into the VelocityContext and do
> Template.merge().
> 
> I noticed the syntax VelocityContext.put() is like that of HashMap, and
> indeed (upon inspection) VelocityContext uses a HashMap internally for
> storage of values passed into VelocityContext.put().
> 
> I intuitively sort of expected to be able to do a
> VelocityContext.putall(Map), instead of having to iterate over my HashMap
> and call VelocityContext.put() casting the keys to String as I go.
> 
> Does anybody else think that VelocityContext.putall(Map) would be usefull?
> or is my use of it out of the ordinary?

It's already there... There's a CTOR for VelocityContext that takes a Map,
and actually uses that as the internal storage....

That's a little different than a putAll(), but gets you most of the way :)

> 
> --
> Kevin Baynes
> 
> 
> PS-
> 
> VelocityContext.putall would be defined in the Context interface (with put),
> so the subclasses would have to implement it. hassle?

Yes - it doesn't make much sense to put on the Context inteface, I think...

> 
> Also, I see that AbstractContext.put() and VelocityContext.internalPut()
> enforce that the key is a String. At some point the rendering engine has to
> pull out the key from HashMap and cast it to String, right?

Not sure if that's the right way to think about it - generally, it looks
into the HashMap with a String key when there's a reference that needs it.

However, it is possible, I would imagine.


> You could get a
> ClassCastException... trust the programmer or not?


-- 
Geir Magnusson Jr.                                      geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>