Page 1 of 1

Queue Method from scope other than globals

PostPosted: Fri Jun 13, 2014 1:12 pm
by Mccourt.cordingley1372837951
Hi All

I have a scope call services within my solution.
I am creating a headless client based on same solution and when i try to queue a function from my scopes.services i get the following

Code: Select all
callback data, name: global methodname: doTest didnt resolve to a method in solution scm_riscm


Is there a special notation to use to queue a function from a new scope?

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 11:08 am
by Mccourt.cordingley1372837951
Anyone from Servoy have some info?

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 3:13 pm
by david
For smart and web clients, the context is the entire solution...all modules. Headless client the context is only the module (and modules included in it) that you specify in the session:

Code: Select all
HeadlessClientFactory.createSessionBean(request,"myServoyModule")


I suspect the scope your are calling is in a module outside the context of your headless client.

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 3:33 pm
by Mccourt.cordingley1372837951
Hi David

All the code is contained within the same solution, no module calls are made.
My code is declared in a scope of the same solution started as a headless client hence i am stumped.

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 3:49 pm
by Harjo
Can you show the line of code, where you call the headlessclient and which syntax you use the set the callback method?

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 4:16 pm
by david
Mccourt.cordingley1372837951 wrote:Hi David

All the code is contained within the same solution, no module calls are made.
My code is declared in a scope of the same solution started as a headless client hence i am stumped.


If that's the case then, without testing I suspect that only global and form methods are available to headless client. These work for sure:

Code: Select all
// Method on a form set with setMainForm(formName)
String results = (String)servoy_hc.executeMethod(null, "aMethod", new Object[]{session, request});

// Method on a form passed in
String results = (String)servoy_hc.executeMethod("formName", "aMethod", new Object[]{session, request});

// Global method
IDataSet results = (IDataSet)servoy_hc.executeMethod(null, "globals.aMethod", new Object[]{session, request});


Not sure about (and would be surprised if they did):

Code: Select all
// Work?
IDataSet results = (IDataSet)servoy_hc.executeMethod(null, "scopes.scopeName.aMethod", new Object[]{session, request});

// Work?
IDataSet results = (IDataSet)servoy_hc.executeMethod(null, "globals.scopes.scopeName.aMethod", new Object[]{session, request});


For headless client work, we long ago started using forms to organize code available to the headless client. Kind of like a poor man's "public" API organization. If you get scopes to work though, that would be ideal.

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 4:31 pm
by Mccourt.cordingley1372837951
HI David

We have created a handler/routing function in the main globals scope to call the method we require in the new scope.
All we are doing is passing the parent scope name, object name and function name as parameters.

Code: Select all
var pa = {paramsArr:paramsArr,parentScope:'services',parentObj:'METHODS',func:methodName}
h.queueMethod(null,'ROUTING',[pa],doCallBack)


and in main globals scope we have

Code: Select all
function ROUTING(obj){
return scopes[obj.parentScope][obj.parentObj][obj.func](obj.paramsArr)
}


But it feels a bit hacky to me.

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 4:37 pm
by Harjo
We use scopes to call a method in the headless client like this:

underlying method is called from a form!
Code: Select all
fv_headlessclient = plugins.headlessclient.createClient("mod_DM_server",null,null,null);
if (fv_headlessclient != null && fv_headlessclient.isValid()) {
fv_headlessclient.queueMethod(null, "scopes.modDMserver.mod_DM_server_sendMails", [vObj], doDone);
}


the callback-method is: doDone, which is also present on the form.
this works fine here.

Re: Queue Method from scope other than globals

PostPosted: Tue Jun 17, 2014 4:48 pm
by david
Cool, so scopes work. Sounds like just need to play around with where to put the callback method. Too bad specifying the callback method isn't done the same way as specifying the trigger method. Would make all the routing a lot easier to figure out.