You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Michael Yui <yc...@sympatico.ca> on 2004/07/23 23:03:08 UTC

How do I access superclass methods and properties?

Hi,

Can I not access the methods or properties of the superclass of an object 
that I put into the context?

Class A {...}

Class B extends A {...}

I tried context.put("test", b);

but $test.getTotal() only works if the getTotal() method is defined in 
class B, not if B inherited it from A.

What am I doing wrong here?


-- 
Best regards,
  Michael        




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


Re: How do I access superclass methods and properties?

Posted by Michael Yui <m...@igather.com>.
Ah, I see. The superclass has to be public also. Thanks.

At 05:12 PM 7/23/2004, you wrote:
>I access superclass methods constantly with no problems.  Just follow
>the rules that Velocity only references public methods in public
>classes.  So A has to be public, B has to be public, and the method
>has to be public.
>
>Barbara Baughman
>X2157
>
>On Fri, 23 Jul 2004, Michael Yui wrote:
>
> > Hi,
> >
> > Can I not access the methods or properties of the superclass of an object
> > that I put into the context?
> >
> > Class A {...}
> >
> > Class B extends A {...}
> >
> > I tried context.put("test", b);
> >
> > but $test.getTotal() only works if the getTotal() method is defined in
> > class B, not if B inherited it from A.
> >
> > What am I doing wrong here?
> >
> >

 > --
 > Best regards,
 >   Michael




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


Re: How do I access superclass methods and properties?

Posted by Barbara Baughman <ba...@utdallas.edu>.
I access superclass methods constantly with no problems.  Just follow
the rules that Velocity only references public methods in public
classes.  So A has to be public, B has to be public, and the method
has to be public.

Barbara Baughman
X2157

On Fri, 23 Jul 2004, Michael Yui wrote:

> Hi,
>
> Can I not access the methods or properties of the superclass of an object
> that I put into the context?
>
> Class A {...}
>
> Class B extends A {...}
>
> I tried context.put("test", b);
>
> but $test.getTotal() only works if the getTotal() method is defined in
> class B, not if B inherited it from A.
>
> What am I doing wrong here?
>
>
> --
> Best regards,
>   Michael
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

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