velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@bodaro.com
Subject Re: Why cant I pass "arrays" to object methods?
Date Sat, 10 Feb 2001 11:31:11 GMT
Thanks, I tried it and it now works well. Very cool, even does method 
overloading. 

Next question ( a bit harder):

I would like to parse the web page (*.vm) myself, sending Velocity 
portions of the template page a bit at a time.

Another way to look at is to send Velocity a portion of the page (a 
snippit of the template) have it process, then my servlet does some other 
stuff, send Velocity more VTL code, do some more stuff,...

Is there a way to stream text to Velocity rather than passing a filename? 
Could I easily? Implment this as an alternative method call in 
VelocityServlet?

Mike Papper

>>>>>>>>>>>>>>>>>> Original Message
<<<<<<<<<<<<<<<<<<

On 2/9/2001, 9:24:19 PM, "Geir Magnusson Jr." <geirm@optonline.net> wrote 
regarding Re: Why cant I pass "arrays" to object methods?:


> It's an ArrayList, not an Object[].  Sorry about that.  We'll update the
> documentation.

> geir

> mike@bodaro.com wrote:
> >
> > Consider the following VTL:
> >
> >     #set ($array=["not", "my"])
> >     #foreach ($r in $array)
> >         $r
> >     #end
> >
> > this works as expected.
> >
> > And if I do
> >
> > $object.methodA("string") - this works, // methodA takes a string
> >
> > But if I do
> >
> > $object.methodB($array) // methodB takes an Object[]
> >
> > and I have a method named method in the object "represented" by $object -
> > and the method takes an Object[] as a parameter it does not work.
> >
> > I have also tried with a methodB that takes a String[] - still dont 
work..
> >
> > BUT if I do
> > $object.methodB($anotherobject) and the $anotherobject represents an
> > actual array (set previously in thecontext of course) then it does work.
> >
> > Any ideas as to why this doesnt work and how to fix it...I think being
> > able to create Object[] arrays using the ["aaa",$raaa] syntax is very
> > important. And the doco says that using ["aaa", $bcd] is a "object array"
> > in the users guide...
> >
> > I am not quite yet on the mailing list so I would appreciate replies to
> > mike@bodaro.com.
> >
> > Mike Papper

> --
> Geir Magnusson Jr.                               geirm@optonline.com
> Velocity : it's not just a good idea. It should be the law.
> http://jakarta.apache.org/velocity

Mime
View raw message