Queue Method from scope other than globals

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

Queue Method from scope other than globals

Postby Mccourt.cordingley1372837951 » Fri Jun 13, 2014 1:12 pm

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?
User avatar
Mccourt.cordingley1372837951
 
Posts: 28
Joined: Wed Jul 03, 2013 9:52 am

Re: Queue Method from scope other than globals

Postby Mccourt.cordingley1372837951 » Tue Jun 17, 2014 11:08 am

Anyone from Servoy have some info?
User avatar
Mccourt.cordingley1372837951
 
Posts: 28
Joined: Wed Jul 03, 2013 9:52 am

Re: Queue Method from scope other than globals

Postby david » Tue Jun 17, 2014 3:13 pm

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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Queue Method from scope other than globals

Postby Mccourt.cordingley1372837951 » Tue Jun 17, 2014 3:33 pm

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.
User avatar
Mccourt.cordingley1372837951
 
Posts: 28
Joined: Wed Jul 03, 2013 9:52 am

Re: Queue Method from scope other than globals

Postby Harjo » Tue Jun 17, 2014 3:49 pm

Can you show the line of code, where you call the headlessclient and which syntax you use the set the callback method?
Harjo Kompagnie
byKom B.V.
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Queue Method from scope other than globals

Postby david » Tue Jun 17, 2014 4:16 pm

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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Queue Method from scope other than globals

Postby Mccourt.cordingley1372837951 » Tue Jun 17, 2014 4:31 pm

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.
User avatar
Mccourt.cordingley1372837951
 
Posts: 28
Joined: Wed Jul 03, 2013 9:52 am

Re: Queue Method from scope other than globals

Postby Harjo » Tue Jun 17, 2014 4:37 pm

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.
Harjo Kompagnie
byKom B.V.
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Queue Method from scope other than globals

Postby david » Tue Jun 17, 2014 4:48 pm

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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 1 guest