You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Alec Swan <al...@gmail.com> on 2011/09/21 01:07:05 UTC

Passing an object as a parameter to a method

Hello,

I am trying to get the following template to work:
${report.generate(project.manager)}

I expect this template to call method Report#generate(User) and pass
project.manager property (of type User) as a parameter.

I tested that ${project.manager} returns correct result and that
${report.generate(null)} calls Report#generate(User) and throws an
NPE. However, calling ${report.generate(project.manager)} results in a
syntax error.

Thanks,

Alec

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Passing an object as a parameter to a method

Posted by Alec Swan <al...@gmail.com>.
Thanks for spotting this!

On Tue, Sep 20, 2011 at 5:09 PM, Nathan Bubna <nb...@gmail.com> wrote:
> and it should be ${report.generate($null)} too, for that matter.  :)
>
> On Tue, Sep 20, 2011 at 4:08 PM, Nathan Bubna <nb...@gmail.com> wrote:
>> ${report.generate($project.manager)}
>>
>> On Tue, Sep 20, 2011 at 4:07 PM, Alec Swan <al...@gmail.com> wrote:
>>> Hello,
>>>
>>> I am trying to get the following template to work:
>>> ${report.generate(project.manager)}
>>>
>>> I expect this template to call method Report#generate(User) and pass
>>> project.manager property (of type User) as a parameter.
>>>
>>> I tested that ${project.manager} returns correct result and that
>>> ${report.generate(null)} calls Report#generate(User) and throws an
>>> NPE. However, calling ${report.generate(project.manager)} results in a
>>> syntax error.
>>>
>>> Thanks,
>>>
>>> Alec
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Passing an object as a parameter to a method

Posted by Nathan Bubna <nb...@gmail.com>.
and it should be ${report.generate($null)} too, for that matter.  :)

On Tue, Sep 20, 2011 at 4:08 PM, Nathan Bubna <nb...@gmail.com> wrote:
> ${report.generate($project.manager)}
>
> On Tue, Sep 20, 2011 at 4:07 PM, Alec Swan <al...@gmail.com> wrote:
>> Hello,
>>
>> I am trying to get the following template to work:
>> ${report.generate(project.manager)}
>>
>> I expect this template to call method Report#generate(User) and pass
>> project.manager property (of type User) as a parameter.
>>
>> I tested that ${project.manager} returns correct result and that
>> ${report.generate(null)} calls Report#generate(User) and throws an
>> NPE. However, calling ${report.generate(project.manager)} results in a
>> syntax error.
>>
>> Thanks,
>>
>> Alec
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Passing an object as a parameter to a method

Posted by Nathan Bubna <nb...@gmail.com>.
${report.generate($project.manager)}

On Tue, Sep 20, 2011 at 4:07 PM, Alec Swan <al...@gmail.com> wrote:
> Hello,
>
> I am trying to get the following template to work:
> ${report.generate(project.manager)}
>
> I expect this template to call method Report#generate(User) and pass
> project.manager property (of type User) as a parameter.
>
> I tested that ${project.manager} returns correct result and that
> ${report.generate(null)} calls Report#generate(User) and throws an
> NPE. However, calling ${report.generate(project.manager)} results in a
> syntax error.
>
> Thanks,
>
> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org