You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by pl...@netscape.net on 2002/07/18 02:07:17 UTC
Using a variable as a method name
This has probably already been asked before, but I looked around for
a bit and couldn't find the answer. Is it possible to do something like:
$a.$b()
and have velocity insert the return value of method $b on $a?
--Paul
__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using a variable as a method name
Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 7/17/02 10:16 PM, "Daniel Rogers" <ii...@acm.org> wrote:
> On Wed, Jul 17, 2002 at 10:07:03PM -0400, Geir Magnusson Jr. wrote:
>>> On Wed, Jul 17, 2002 at 08:07:17PM -0400, plynchnlm@netscape.net wrote:
>>>> $a.$b()
>>
>> It won't work.
>
> Whoops, missed the $ in front of the b. However, $a.b() should work,
> unless I'm missing what the original goal was.
>
$a.b() will work. It think the original goal was to have interpolation to
do things like have $b hold the property name to be invoked on $a.
--
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using a variable as a method name
Posted by Daniel Rogers <ii...@acm.org>.
On Wed, Jul 17, 2002 at 10:07:03PM -0400, Geir Magnusson Jr. wrote:
> > On Wed, Jul 17, 2002 at 08:07:17PM -0400, plynchnlm@netscape.net wrote:
> >> $a.$b()
>
> It won't work.
Whoops, missed the $ in front of the b. However, $a.b() should work,
unless I'm missing what the original goal was.
Daniel
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using a variable as a method name
Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 7/17/02 8:28 PM, "Daniel Rogers" <ii...@acm.org> wrote:
> On Wed, Jul 17, 2002 at 08:07:17PM -0400, plynchnlm@netscape.net wrote:
>> This has probably already been asked before, but I looked around for
>> a bit and couldn't find the answer. Is it possible to do something like:
>> $a.$b()
>> and have velocity insert the return value of method $b on $a?
>>
>> --Paul
>
> Give it a try :-) If $a is referencing some object in the context with a
> method b (that takes no arguments), then it should work.
>
It won't work.
Velocity should parse that to be
$a
.
$b
()
Because $a.$b isn't valid.
--
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using a variable as a method name
Posted by Daniel Rogers <ii...@acm.org>.
On Wed, Jul 17, 2002 at 08:07:17PM -0400, plynchnlm@netscape.net wrote:
> This has probably already been asked before, but I looked around for
> a bit and couldn't find the answer. Is it possible to do something like:
> $a.$b()
> and have velocity insert the return value of method $b on $a?
>
> --Paul
Give it a try :-) If $a is referencing some object in the context with a
method b (that takes no arguments), then it should work.
Daniel
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>