• 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: Best way to run static class method from a string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to run static class method from a string?


  • Subject: Re: Best way to run static class method from a string?
  • From: James Cicenia <email@hidden>
  • Date: Tue, 09 Dec 2014 10:22:00 -0600

I want to run a method called availableKeys which just returns an NSArray of keypaths for that Entity.

I will be creating a picker of keys that are pre determined. I was going to use the UserInfo but it made EOModeler act a bit funny.
So I am doing something like:

    public NSMutableDictionary availableKeys(){
        if(availableKeys == null){
            availableKeys.takeValueForKeyPath("Name", "name”);
            availableKeys.takeValueForKeyPath("--- Dates ---", "-DATES-");
            availableKeys.takeValueForKeyPath("Active Date", "activeDt");
        }
        return availableKeys;
    }

So in my “Generic” pick list component I want to pass in the displayGroup, let them pick the columns of the report, and then process.





On Dec 9, 2014, at 10:14 AM, Ramsey Gurley <email@hidden> wrote:

EOEntity entity = EOModelGroup.defaultModelGroup().entityNamed(entityName);
Class class = _NSUtilities.classWithName(entity.className());
Method method = class.getMethod(methodName, parameterTypes);
method.invoke(null, parameters); //null target for static methods

You could do it through java’s reflection APIs, but that sounds really fishy. Maybe if you explain what you are trying to accomplish, we could offer better insight. For instance, you may be better served using the clazz pattern if you want static methods you can override.



On Dec 9, 2014, at 8:37 AM, James Cicenia <email@hidden> wrote:


I have a string that is an EntityName.
I want to run that entity’s static class method.

do I have to do this?:

       EOEnterpriseObject myClass = EOUtilities.createAndInsertInstance( ec, entityName) ;

I really don’t want to create an instance.

Thanks
James

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
  • Follow-Ups:
    • Re: Best way to run static class method from a string?
      • From: Matthew Ness <email@hidden>
    • Re: Best way to run static class method from a string?
      • From: Ramsey Gurley <email@hidden>
    • Google Calendar access from WO
      • From: Greg Smith <email@hidden>
References: 
 >Best way to run static class method from a string? (From: James Cicenia <email@hidden>)
 >Re: Best way to run static class method from a string? (From: Ramsey Gurley <email@hidden>)

  • Prev by Date: Re: Best way to run static class method from a string?
  • Next by Date: d2w add displayPropertyKeys in new ListPageInterface
  • Previous by thread: Re: Best way to run static class method from a string?
  • Next by thread: Google Calendar access from WO
  • Index(es):
    • Date
    • Thread