You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Supun Kamburugamuva <su...@gmail.com> on 2007/04/27 18:50:48 UTC

Need a clarifcation about some issues

Hi,
I have been playing with Velocity in the past few days. By doing so I
encountered couple of problems. I'm not sure weather these are the
documented behavior so I thought I should ask the list.

1.I couldn't set a property after I initialize the Velocity Engine
(After calling the init() method).  Here the particular property I was
trying to set was MAX_NUMBER_LOOPS property.

2.I couldn't call inner class methods. I put an inner class object in
to Velocity context and then tried to call its methods from the
template. But it didn't work. Velocity just outputs the calling method
name.

Thanks,
Supun.

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


Re: Need a clarifcation about some issues

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Supun,

Supun Kamburugamuva wrote:
> 2.I couldn't call inner class methods. I put an inner class object in
> to Velocity context and then tried to call its methods from the
> template. But it didn't work. Velocity just outputs the calling method
> name.

Can you verify that the inner class (and the property accessor) is
public? I think introspection is blocked when a private/protected inner
class is involved, so it's possible that Velocity actually can't read
the values from your object.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGMjgY9CaO5/Lv0PARAh2FAJ0QCbpS3iy7FnqGrPcAOwouUQzFIwCgpqqI
lJqH+n5Wc8/dFKXNTmRjKnM=
=yUfv
-----END PGP SIGNATURE-----

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


Re: Need a clarifcation about some issues

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Supun Kamburugamuva" <su...@gmail.com> writes:

Yes, I was wrong here. private inner classes not working is perfectly
fine (private regular classes do not work either... )

	Best regards
		Henning


>Hi,

>My inner class was a private one. When I made it public everything
>worked well. Is it a issue that private inner classes are not working?
>(Henning suggested to open a Jira).

>Thanks,
>Supun.



>On 4/29/07, Nathan Bubna <nb...@gmail.com> wrote:
>> On 4/28/07, Henning P. Schmiedehausen <hp...@intermeta.de> wrote:
>> > "Supun Kamburugamuva" <su...@gmail.com> writes:
>> >
>> > >2.I couldn't call inner class methods. I put an inner class object in
>> > >to Velocity context and then tried to call its methods from the
>> > >template. But it didn't work. Velocity just outputs the calling method
>> > >name.
>> >
>> > Yes, this is AFAIK a known restriction. Can you open a JIRA issue
>> > for this so that it does not get lost?
>>
>> No, even VelocityTools uses inner classes extensively.  If the class
>> is public and the method is public, you should be good to go.  It
>> doesn't make any difference whether the class is inner or outer.
>>
>> >         Best regards
>> >                 Henning
>> >
>> > --
>> > Henning P. Schmiedehausen  -- hps@intermeta.de | J2EE, Linux,               |gls
>> > 91054 Buckenhof, Germany   -- +49 9131 506540  | Apache person              |eau
>> > Open Source Consulting, Development, Design    | Velocity - Turbine guy     |rwc
>> >                                                                             |m k
>> > INTERMETA - Gesellschaft fuer Mehrwertdienste mbH - RG Fuerth, HRB 7350     |a s
>> > Sitz der Gesellschaft: Buckenhof. Geschaeftsfuehrer: Henning Schmiedehausen |n
>> >
>> >                "Save the cheerleader. Save the world."
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: dev-help@velocity.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: dev-help@velocity.apache.org
>>
>>

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

-- 
Henning P. Schmiedehausen  -- hps@intermeta.de | J2EE, Linux,               |gls
91054 Buckenhof, Germany   -- +49 9131 506540  | Apache person              |eau
Open Source Consulting, Development, Design    | Velocity - Turbine guy     |rwc
                                                                            |m k
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH - RG Fuerth, HRB 7350     |a s
Sitz der Gesellschaft: Buckenhof. Geschaeftsfuehrer: Henning Schmiedehausen |n

	       "Save the cheerleader. Save the world."

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


Re: Need a clarifcation about some issues

Posted by Nathan Bubna <nb...@gmail.com>.
On 4/29/07, Supun Kamburugamuva <su...@gmail.com> wrote:
> Hi,
>
> My inner class was a private one. When I made it public everything
> worked well. Is it a issue that private inner classes are not working?
> (Henning suggested to open a Jira).

No.  Classes and methods that are private or protected should not be
accessible within a template.  No need to open an issue for this.

> Thanks,
> Supun.
>
>
>
> On 4/29/07, Nathan Bubna <nb...@gmail.com> wrote:
> > On 4/28/07, Henning P. Schmiedehausen <hp...@intermeta.de> wrote:
> > > "Supun Kamburugamuva" <su...@gmail.com> writes:
> > >
> > > >2.I couldn't call inner class methods. I put an inner class object in
> > > >to Velocity context and then tried to call its methods from the
> > > >template. But it didn't work. Velocity just outputs the calling method
> > > >name.
> > >
> > > Yes, this is AFAIK a known restriction. Can you open a JIRA issue
> > > for this so that it does not get lost?
> >
> > No, even VelocityTools uses inner classes extensively.  If the class
> > is public and the method is public, you should be good to go.  It
> > doesn't make any difference whether the class is inner or outer.
> >
> > >         Best regards
> > >                 Henning
> > >
> > > --
> > > Henning P. Schmiedehausen  -- hps@intermeta.de | J2EE, Linux,               |gls
> > > 91054 Buckenhof, Germany   -- +49 9131 506540  | Apache person              |eau
> > > Open Source Consulting, Development, Design    | Velocity - Turbine guy     |rwc
> > >                                                                             |m k
> > > INTERMETA - Gesellschaft fuer Mehrwertdienste mbH - RG Fuerth, HRB 7350     |a s
> > > Sitz der Gesellschaft: Buckenhof. Geschaeftsfuehrer: Henning Schmiedehausen |n
> > >
> > >                "Save the cheerleader. Save the world."
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: dev-help@velocity.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

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


Re: Need a clarifcation about some issues

Posted by Supun Kamburugamuva <su...@gmail.com>.
Hi,

My inner class was a private one. When I made it public everything
worked well. Is it a issue that private inner classes are not working?
(Henning suggested to open a Jira).

Thanks,
Supun.



On 4/29/07, Nathan Bubna <nb...@gmail.com> wrote:
> On 4/28/07, Henning P. Schmiedehausen <hp...@intermeta.de> wrote:
> > "Supun Kamburugamuva" <su...@gmail.com> writes:
> >
> > >2.I couldn't call inner class methods. I put an inner class object in
> > >to Velocity context and then tried to call its methods from the
> > >template. But it didn't work. Velocity just outputs the calling method
> > >name.
> >
> > Yes, this is AFAIK a known restriction. Can you open a JIRA issue
> > for this so that it does not get lost?
>
> No, even VelocityTools uses inner classes extensively.  If the class
> is public and the method is public, you should be good to go.  It
> doesn't make any difference whether the class is inner or outer.
>
> >         Best regards
> >                 Henning
> >
> > --
> > Henning P. Schmiedehausen  -- hps@intermeta.de | J2EE, Linux,               |gls
> > 91054 Buckenhof, Germany   -- +49 9131 506540  | Apache person              |eau
> > Open Source Consulting, Development, Design    | Velocity - Turbine guy     |rwc
> >                                                                             |m k
> > INTERMETA - Gesellschaft fuer Mehrwertdienste mbH - RG Fuerth, HRB 7350     |a s
> > Sitz der Gesellschaft: Buckenhof. Geschaeftsfuehrer: Henning Schmiedehausen |n
> >
> >                "Save the cheerleader. Save the world."
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

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


Re: Need a clarifcation about some issues

Posted by Nathan Bubna <nb...@gmail.com>.
On 4/28/07, Henning P. Schmiedehausen <hp...@intermeta.de> wrote:
> "Supun Kamburugamuva" <su...@gmail.com> writes:
>
> >2.I couldn't call inner class methods. I put an inner class object in
> >to Velocity context and then tried to call its methods from the
> >template. But it didn't work. Velocity just outputs the calling method
> >name.
>
> Yes, this is AFAIK a known restriction. Can you open a JIRA issue
> for this so that it does not get lost?

No, even VelocityTools uses inner classes extensively.  If the class
is public and the method is public, you should be good to go.  It
doesn't make any difference whether the class is inner or outer.

>         Best regards
>                 Henning
>
> --
> Henning P. Schmiedehausen  -- hps@intermeta.de | J2EE, Linux,               |gls
> 91054 Buckenhof, Germany   -- +49 9131 506540  | Apache person              |eau
> Open Source Consulting, Development, Design    | Velocity - Turbine guy     |rwc
>                                                                             |m k
> INTERMETA - Gesellschaft fuer Mehrwertdienste mbH - RG Fuerth, HRB 7350     |a s
> Sitz der Gesellschaft: Buckenhof. Geschaeftsfuehrer: Henning Schmiedehausen |n
>
>                "Save the cheerleader. Save the world."
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

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


Re: Need a clarifcation about some issues

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Supun Kamburugamuva" <su...@gmail.com> writes:

>2.I couldn't call inner class methods. I put an inner class object in
>to Velocity context and then tried to call its methods from the
>template. But it didn't work. Velocity just outputs the calling method
>name.

Yes, this is AFAIK a known restriction. Can you open a JIRA issue
for this so that it does not get lost?

	Best regards
		Henning

-- 
Henning P. Schmiedehausen  -- hps@intermeta.de | J2EE, Linux,               |gls
91054 Buckenhof, Germany   -- +49 9131 506540  | Apache person              |eau
Open Source Consulting, Development, Design    | Velocity - Turbine guy     |rwc
                                                                            |m k
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH - RG Fuerth, HRB 7350     |a s
Sitz der Gesellschaft: Buckenhof. Geschaeftsfuehrer: Henning Schmiedehausen |n

	       "Save the cheerleader. Save the world."

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


Re: Need a clarifcation about some issues

Posted by Nathan Bubna <nb...@gmail.com>.
On 4/27/07, Supun Kamburugamuva <su...@gmail.com> wrote:
> Hi,
> I have been playing with Velocity in the past few days. By doing so I
> encountered couple of problems. I'm not sure weather these are the
> documented behavior so I thought I should ask the list.
>
> 1.I couldn't set a property after I initialize the Velocity Engine
> (After calling the init() method).  Here the particular property I was
> trying to set was MAX_NUMBER_LOOPS property.

Correct.  Properties must be set prior to initialization/use of the
runtime.  At this point, there is no support for changing properties
in a runtime instance that's already in use.

> 2.I couldn't call inner class methods. I put an inner class object in
> to Velocity context and then tried to call its methods from the
> template. But it didn't work. Velocity just outputs the calling method
> name.

Christopher is right here.  Inner classes work just fine (i use them a
lot), but they must be declared public just like any other classes you
are trying access in a template.

> Thanks,
> Supun.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

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