How to invoke methods in the method editor from a plugin

Questions and answers on developing, deploying and using plugins and JavaBeans

How to invoke methods in the method editor from a plugin

Postby sdevlin » Thu Jul 01, 2004 10:41 pm

I'm hoping that this is an easy answer...

1) How do I invoke methods, created in servoy developer method editor, from my client plugin. This is possible right?

2) More specifically, I would like to have the java script methods invoked in response to gui events in the client plugin and bean. Any thoughts?..

Thanks,
Sean
sdevlin
 
Posts: 125
Joined: Tue Apr 13, 2004 3:33 am

Postby stephan » Thu Jul 01, 2004 11:14 pm

I've found this in the scheduler plugin and this would answer question 1:

Code: Select all
Function method = (Function)  object;
Object args[] = (Object[]) object;

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                Context context = Context.enter();
                try {
                    method.call(context, method.getParentScope(), method.getParentScope(), args);
                } catch (JavaScriptException e) {
                    e.printStackTrace();
                } finally {
                    Context.exit();
                }
            }

        });


To pass the Function object from the Editor (corresponding to a method) you write the name of the method without the parentheses (ie: write hello, not hello()).

About question 2 I don't know what to say, I guess it depends on the gui events you're talking about ... if you discover something post it here!
stephan
 
Posts: 76
Joined: Thu Jun 03, 2004 3:30 pm

Scheduler Source Code

Postby sdevlin » Thu Jul 01, 2004 11:55 pm

Well this is a start. I have the latest beta but the Scheduler plugin does not come with source code. How did you get it??
sdevlin
 
Posts: 125
Joined: Tue Apr 13, 2004 3:33 am

Postby Jan Blok » Mon Jul 05, 2004 2:36 pm

The scheduler plugin will contain the source in Servoy 2.1 beta4 (from which the snipped above is a part)
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby pbakker » Fri Aug 13, 2004 9:59 pm

Did you guys got it working, the invokation of Servoy Methods from inside a plugin (without using the jar that the Scheduler plugin uses)?

If so, would you be willing to share some code? :D

Been trying to get it working, but I'm not really getting anywhere....

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Jan Blok » Fri Aug 13, 2004 10:10 pm

The scheduler jar is not needed to invoke methods from a plugin, the opensource scheduler plugin does show how it works .
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 18 guests