Headless Client use

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

Headless Client use

Postby madimane » Thu Aug 26, 2010 3:54 am

Hi All,

I try to use Headless Client but without success.

I have a solution "Sola"
I have a form "FormA" which contains a method "methA" and a callback method
.

I have tried different syntax:
Code: Select all
function onActionLaunchClient()
{
         client = plugins.headlessclient.createClient('Sola','login','pwd',null);
         // I tried this
   client.queueMethod(null,"forms.FormA.methA",["something"],callback);
       // I tried this
        client.queueMethod(null,"FormA.methA",["something"],callback);
       // I tried a global method
        client.queueMethod(null,"globalMethod",["something"],callback);
}
function methA(param)
{
   // do something
}

function callback(event) {
    // do some stuff
   if (JSClient.CALLBACK_EVENT == event.getType())
   {
      // handle normal execute of remote method
      application.output("work");
   }
   else if (JSClientC.ALLBACK_EXCEPTION_EVENT == event.getType())
   {
      // handle exception execute of remote method
      application.output("notwork");
   }
   client.shutdown()
}


In all the case I get CALLBACK_EXCEPTION_EVENT in my callback method :(

If someone can explain me what am I doing wrong.

Thank you in advance for your support
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby pbakker » Thu Aug 26, 2010 10:26 am

If you look at the sample code for the queueMethod function, you see this:
Code: Select all
// this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method
   jsclient.queueMethod(null, "remoteMethod", [x], callback);


So, translated to your example, the following should work:
Code: Select all
         client = plugins.headlessclient.createClient('Sola','login','pwd',null);
         // I tried this
   client.queueMethod('FormA',"methA",["something"],callback);
        // I tried a global method
        client.queueMethod(null,"globalMethod",["something"],callback)


So, the latter method queued, the global method should've worked already in your example. Are you sure you got the name correct?
In the sample code you can also see that the details of the exception that occurred is stored in teh data property of the event:
Code: Select all
else if (event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT)
   {
      application.output("exception callback, name: " + event.data);
   }


You can check this to get more info on what exactly happened.

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

Re: Headless Client use

Postby madimane » Thu Aug 26, 2010 4:11 pm

Thank you Paul for the reply.

With the formName in the context param, I'm getting now a CALLBACK_EVENT, but my method is not called!!

I have the following error in my servoy_log.txt
Code: Select all
2010-08-26 09:51:03,868 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:03,915 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:34,603 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:34,634 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:52,775 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded


My solution has a mustAuthenticate flag on, so I have a login and authenticator modules.

Any suggestion are more than welcome
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby ptalbot » Thu Aug 26, 2010 5:14 pm

Hi Othmane,

I don't thing these errors are related to the headless_client plugin: it indicates that you seem to have 2 file.jar in your class path (check in /beans and /plugins maybe?)

Hope this helps,
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Headless Client use

Postby madimane » Thu Aug 26, 2010 5:42 pm

Thank you Patrick,

You're right, I forgot to keep off an old version of file.jar from my plugins folder.

Now I have no error in my log file, but my method is not called by the headless_client!!!
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby madimane » Thu Aug 26, 2010 9:55 pm

I noted then even if I provide a methodName that doesn't exist or formname that dosn't exist too
it doesn't generate an exception!!

I really don't undersatand why my method is not called and what is strange, is that i dont have any error.

Any suggestion guys to debug that?
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby madimane » Fri Aug 27, 2010 3:03 am

I made a sample solution that not require Authentication.
In this case my method is called!!!

should I authenticate the headless_client somewhere?
I guess that createClient do that?

Thank you for any suggestion
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby pbakker » Fri Aug 27, 2010 9:43 am

When you create the client, you have to supply credentials, you do so in your code already:
Code: Select all
client = plugins.headlessclient.createClient('Sola','login','pwd',null);


I assumed you were passing in correct credentials?

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

Re: Headless Client use

Postby madimane » Fri Aug 27, 2010 4:37 pm

yes of course,I provide the right credentials.

I tried to trace where the headless_client passes using application.output with LOGINLEVEL.EROOR
I see that it goes up the onload of form login.
I tried to re-authenticate it with security.authenticate ('module_authenticator' methLogin, [params]).
I saw that it is authenticated Successfully But What Happened after, this is my big question!

Thank you for your help
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby jcompagner » Mon Aug 30, 2010 11:28 am

what happens if you just use security.login() instead of security.authenticate()
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Headless Client use

Postby madimane » Mon Aug 30, 2010 3:38 pm

Hi Johan,

I tried security.login() directly in my module Login instead of doing it in the authenticator! module but without success.

Thank you for your support
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Hdless Client doesn't call a method when authentication is o

Postby madimane » Mon Sep 06, 2010 6:27 am

Hi all,

I've made a simple solution that illustrates my problem of launching a headlessClient through a solution that requires an authentication.

The solution includes three modules:

main solution: testHeadlessClient
Solution login: SGM_LOGIN
solution authenticator: SGM_AUTHENTICATOR

To test the behaviour
1) launch the solution
2) click on the login button to log
3) click on the button "Launch headless client" who creates a client and associates to it the method "CallMe" which is simply an output of the string "headless method executed" with a LOGGINLEVEL.ERROR.

When I disable authentication (mustAuthenticate = false and loginSolutionName = default), everything works perfectly and my method "CallMe" is called by the headlessClient.

When I enable authentication (mustAuthenticate = true and loginSolutionName = SGM_LOGIN), the headless client is created and the onload method of my login form is called but unfortunately, the method "CallMe" is not called by the headlessClient!:(

I really do not know what else to test and I really need to use the headless client to associate to it a long process that we have to do in a solution we are developping in version 5.2.
We have another solutions developped with version 5.1.4 witch use batchProcessor which is in effect a headlessClient, So I'm wondering if they will still work if we passes to the 5.2 version :|
I hope that I was clear enough and If someone can explain to me what I'm doing wrong, that would be very appreciated.

Thank you for your support
Attachments
testHeadlessClient.servoy
(20.98 KiB) Downloaded 375 times
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby jcompagner » Mon Sep 06, 2010 10:08 am

please file (viewtopic.php?f=8&t=6062) a case with this information.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Headless Client use

Postby madimane » Mon Sep 06, 2010 10:34 pm

Ok, I've opened a case and its id is 317807.

Thank you for your support
Othmane himadi
Analyst / Developper
Freelancer
---------------------
Whether we want it or not, being a developer means documenting our code is a necessity
User avatar
madimane
 
Posts: 85
Joined: Tue Oct 13, 2009 5:16 am
Location: Montréal,QC,Canada

Re: Headless Client use

Postby rgansevles » Wed Sep 08, 2010 9:01 pm

Othmane,

Can you try the same solution in a real server-smartclient setup, so not in developer?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Next

Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 11 guests