• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question about java method calling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Re: Question about java method calling (From: Kevin Xiaowen Ren <email@hidden>)
 >Question about java method calling (From: Kevin Xiaowen Ren <email@hidden>)
 >Re: Question about java method calling (From: Fabrice Truillot <email@hidden>)

  • Prev by Date: Re: WODisplayGroup and nextBatch/previousBatch
  • Next by Date: Save-In: "Folder Name" in Save-As Dialog Box.
  • Previous by thread: Re: Question about java method calling
  • Next by thread: WO and a Quicktime Movie using SMIL
  • Index(es):
    • Date
    • Thread