running my first SHC

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

running my first SHC

Postby jdbruijn » Fri Oct 25, 2013 3:08 pm

I'm trying to get my first SHC solution to work, but it does not seem to run the method that I put in the queue.
This is my code to start the SHC and the callback function:
Code: Select all
function startSHC(event) {
   var obj = new Object;
   obj.startdate = vStartDate;
   obj.enddate = vEndDate;
   obj.fs = foundset;
   
   application.output('SHC Starting ...')
   try
   {
      headless = plugins.headlessclient.createClient('CCS_headless',null,null,null);
      if(headless != null && headless.isValid()){
         application.output('SHC Started, queueing method')
         headless.queueMethod(null,'sendReports',[obj], onCallbackSHC);
         application.output('SHC method queued');
      }else{
         application.output('SHC not started.')
      }
   }
   catch(e)
   {
      application.output('SHC error: '+e.message);
   }
}

/**
* @param {JSEvent} event
*
* @properties={typeid:24,uuid:"A9B161F3-4634-4BDD-BE06-3EE1D28F2C47"}
*/
function onCallbackSHC(event)
{
   application.output('SHC - callback')
   // do some stuff
   if (JSClient.CALLBACK_EVENT == event.getType())
   {
      // handle normal execute of remote method
   }
   else if (JSClient.CALLBACK_EXCEPTION_EVENT == event.getType())
   {
      // handle exception execute of remote method
   }
   headless.shutdown()
}

The solution CCS_headless is a module of my main solution. It has 2 global methods: onOpen and sendReports. Both methods start with an application.output, the one for onOpen is shown in the log, but the one for sendReports is not.
What am I missing here?
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: running my first SHC

Postby Ruben79 » Fri Oct 31, 2014 3:08 pm

In case you didn't solve it yet: I think you have to specify the scope for the queued method, so should be something like
Code: Select all
headless.queueMethod(null,'globals.sendReports',[obj], onCallbackSHC);
//or
headless.queueMethod(null,'scopes.yourScope.sendReports',[obj], onCallbackSHC);


Also, I think you cannot pass in foundsets as an argument so you might want to try running it without arguments first.
Ruben de Jong
Stb Software Development
SAN Partner

Stb Software Development - http://www.stb.nl
User avatar
Ruben79
 
Posts: 97
Joined: Wed Apr 18, 2007 12:43 pm


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 5 guests