Re: Question about java method calling
Re: Question about java method calling
- Subject: Re: Question about java method calling
- From: Kevin Xiaowen Ren <email@hidden>
- Date: Fri, 15 Oct 2004 08:56:06 +1300
Hi, Fabrice,
Got your answer, but I found NSNotification could be used for this issue.
Where can I find some example for using NSNotification?
Is delegation in C# coming from this idea?
thanks
kevin
At 02:13 7/10/2004 +0200, you wrote:
On 7 oct. 04, at 00:30, Kevin Xiaowen Ren wrote:
Could I know the code for " The default implementation of
WODirectAction's performActionName() appends "Action" to the method's
argument. "?
I am trying to call some dynamic method by method name string in class.?
Well, since we don't have the WebObjects source we have to write something
by ourself...
Finding the method `name` for the class `clazz` :
import java.lang.reflect.*;
Method findMethod (String name, Class clazz)
{
Method[] methods = clazz.getMethods ();
for (int loop = 0; loop < methods.length; ++ loop)
{
if (methods[loop].getName ().equals (name))
return method;
}
return null;
}
Method invocation :
Object target = ...
Method method = findMethod ("myMethodByName", target.getClass ());
Object result = method.invoke (target, new Object[] { `method
arguments` })
Pretty easy, isn't it ? Reflection is a very powerful feature, but can be
costly so be careful. :)
--
Fabrice Truillot
Men in Silicium Ltd. - ã±ã¤ç´ ã®äºº </blockquote></x-html>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden