# application.isHeadless()

**URL:** <https://forum.servoy.com/t/application-isheadless/4592>\
**Category:** Classic Servoy\
**Created:** [August 10, 2005, 11:45am UTC](https://forum.servoy.com/t/application-isheadless/4592 "2005-08-10T11:45:29Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 10, 2005, 11:45am UTC](https://forum.servoy.com/t/application-isheadless/4592/1 "2005-08-10T11:45:29Z")

</div>

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

```auto
application.isHeadless()

```

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

Thanks  
Patrick

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [August 10, 2005, 4:09pm UTC](https://forum.servoy.com/t/application-isheadless/4592/2 "2005-08-10T16:09:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Harry\_Catharell](https://avatars.discourse-cdn.com/v4/letter/h/e19adc/32.png) [@Harry\_Catharell](https://forum.servoy.com/u/Harry_Catharell)\
**Post date:** [August 10, 2005, 6:07pm UTC](https://forum.servoy.com/t/application-isheadless/4592/3 "2005-08-10T18:07:17Z")

</div>

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

Cheers  
Harry

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 10, 2005, 6:43pm UTC](https://forum.servoy.com/t/application-isheadless/4592/4 "2005-08-10T18:43:39Z")

</div>

exactly. ![:)]( "Smile") 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.

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [August 10, 2005, 7:40pm UTC](https://forum.servoy.com/t/application-isheadless/4592/5 "2005-08-10T19:40:25Z")

</div>

I’m not saying it’s not a GOOD feature request! ![:D]( "Very Happy")  
I think it would be a great feature as well.

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [August 11, 2005, 6:56am UTC](https://forum.servoy.com/t/application-isheadless/4592/6 "2005-08-11T06:56:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 11, 2005, 7:28am UTC](https://forum.servoy.com/t/application-isheadless/4592/7 "2005-08-11T07:28:11Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [August 11, 2005, 7:34am UTC](https://forum.servoy.com/t/application-isheadless/4592/8 "2005-08-11T07:34:27Z")

</div>

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]( "Razz")

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

Paul

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [August 13, 2005, 7:02am UTC](https://forum.servoy.com/t/application-isheadless/4592/9 "2005-08-13T07:02:08Z")

</div>

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

```auto
globals.headless = arguments[0];

```

when 0 the running client is not headless, when 1 it is ![:)]( "Smile")

Cheers

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 13, 2005, 8:03am UTC](https://forum.servoy.com/t/application-isheadless/4592/10 "2005-08-13T08:03:19Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [August 13, 2005, 10:04am UTC](https://forum.servoy.com/t/application-isheadless/4592/11 "2005-08-13T10:04:00Z")

</div>

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

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 13, 2005, 12:38pm UTC](https://forum.servoy.com/t/application-isheadless/4592/12 "2005-08-13T12:38:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [August 13, 2005, 1:08pm UTC](https://forum.servoy.com/t/application-isheadless/4592/13 "2005-08-13T13:08:49Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 13, 2005, 1:10pm UTC](https://forum.servoy.com/t/application-isheadless/4592/14 "2005-08-13T13:10:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [August 13, 2005, 1:14pm UTC](https://forum.servoy.com/t/application-isheadless/4592/15 "2005-08-13T13:14:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 14, 2005, 11:33am UTC](https://forum.servoy.com/t/application-isheadless/4592/16 "2005-08-14T11:33:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [August 14, 2005, 1:23pm UTC](https://forum.servoy.com/t/application-isheadless/4592/17 "2005-08-14T13:23:34Z")

</div>

> 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:
> 
> ```auto
> 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.
