application.isHeadless()

Hello,

I have a problem with the headless client: some things I do a startup are not really useful in a HC (showing some start screen in a dialog etc.). Could we have a

application.isHeadless()

to figure out if the current client has a head or not?

Thanks
Patrick

When the client is headless - any dialog you show at startup (part of your startup method) is ignored already automatically.

Yes, but it sounds as though Patrick would like to test for the type of client connection at startup and branch accordingly !

Cheers
Harry

exactly. :) And I can show you a log that is full of errors because I do things in my solution that are not good for a headless. So I try to prevent these problems.

I’m not saying it’s not a GOOD feature request! :D
I think it would be a great feature as well.

Through the Servoy Plugin API, you can allready test if a connection to the server is a Developer or a Client and with some work if it’s a RunTime solution.

Maybe there’s allready a way to determine it’s a HeadLess client as well.

Haven’t done any work with the Headless Client myself, so haven’t looked at this, but maybe it’s possible in the API allready and just needs to be exposed through a plugin.

Paul

I suppose you can program half of Servoy yourself if you know how to and have the time to do it. But maybe that one is not hard to do for Servoy…

Mmm, not sure about that half of Servoy we could program ourselves… I think that’s a big underestimation of what Servoy is and does… :P

You are right, but I’m just giving you an option here. Take it or leave it, that’s up to you.

Paul

You can test for Servoy being headless. When you define a startup method you can add something like this in the first few lines:

globals.headless = arguments[0];

when 0 the running client is not headless, when 1 it is :)

Cheers

I am not sure this helps. My problems arise from the startup method. If I call my headless, I need methods, that are run after the startup method. I needed to pass that 1 to the startup method, but that is not the one I want to call…

Imo this helps because what you can do is this (btw I use this in one of my solutions from the beginning):

globals.headless = arguments[0];

if (globals.headless) {
  //run the method(s) you need to run when the client is headless;
} else {
 //run the method(s) you want/need to run when the client is a normal client;
}

The globals.headless variable is needed anyway if you make use of dialogs since you can not use these in a headless client anyway...

Ofcourse you can run this at the beginning of your startup method or at the end or, if that suits you better, from your first form that you open at the onShow or onLoad event.

I get your idea. This is just like application.isHeadless(). But what is your arguments[0] or where does it come from?

As I said before, my problems lay in the startup method. So when I call my JSP, the headles starts, runs the startup method and then comes to the method actually called. At what point now do I get a arguments[0] == true if I start a HC?

Hmm, I see, now that I am awake, that I have not been complete at all.

When you do the jsp call to the solution you can give the solution variables like you can when calling a method. Your call could look like:

whatevername_hc = HeadlessClientFactory.createSessionBean(request,"solutionname","loginname","password",new Object[]{"1"});

The Object array is (in my case) filled with the value 1. And now, your startup method can use that array named arguments. The first value in the variable can be accessed like you would access an array normally (arguments[0]) and holds that value 1.

Now we are getting somewhere! So this parameter Array is only available in the startup method?

Yep, like you would have when calling a ‘normal’ method with variables attached…

Thanks, Marcel! I tested that and it looks like that works fine for me. So I can withdraw my feature request, since the feature is already available somehow.

IT2BE:
Hmm, I see, now that I am awake, that I have not been complete at all.

When you do the jsp call to the solution you can give the solution variables like you can when calling a method. Your call could look like:

whatevername_hc = HeadlessClientFactory.createSessionBean(request,"solutionname","loginname","password",new Object[]{"1"});

The Object array is (in my case) filled with the value 1. And now, your startup method can use that array named arguments. The first value in the variable can be accessed like you would access an array normally (arguments[0]) and holds that value 1.

This is a FANTASTIC tip! Should be on Servoy Magazine!

Thanks a lot for sharing it.