[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    Re: Very OT: Java Reflection?
From:       "Craig R. McClanahan" <craigmcc () apache ! org>
Date:       2003-01-30 21:01:07
[Download RAW message or body]



On Wed, 29 Jan 2003, V. Cekvenich wrote:

> Date: Wed, 29 Jan 2003 07:12:47 -0500
> From: V. Cekvenich <vc@basebeans.com>
> Reply-To: Struts Developers List <struts-dev@jakarta.apache.org>
> To: struts-dev@jakarta.apache.org
> Subject: Very OT: Java Reflection?
> 
> Someone care to help me out on OT reflection?
> 
> Here is the situation:
> My base class has a reflection (in execute) that does this :
> 
> Method eventMethod = this.getClass().getMethod(methodName, args);
> 
> and same class has
> onDefaultExec() {}
> (or full code here:
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/ROOT/src/basicWebLib/org/apache/basicWebLib/dispatch/BaseTilesActionHandler.java
>  )
> 
> The concrete (derived)  class works great with reflection, it calls the
> method in that class.
> 
> However, the problem is that if the concrete class does not have a
> reflected method, it won't go look back in the base class for the method
> name. In my case onDefaultExec and others are in base, not the instance
> class.
> 
> To restate, if I reflect for a method that is concrete class, great, but
> when I reflect for a method for a base class I get
> reflect.InvocationTargetException
> It's not looking back.
> 

Check out the methods :-) in MethodUtils from commons-beanutils -- they
know how to search through superclasses (and implemented interfaces) for
the correct Method object to call invooke() on.

> ?
> 
> tia,
> Vic

Craig

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic