Handling "Event" Parameter when running as Headless Client

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

Handling "Event" Parameter when running as Headless Client

Postby sabbatarian7 » Tue May 03, 2016 7:30 am

Hello,

What I am doing is converting a process to be run as headless client, where previously it was running as a form process (User clicks, it starts, and run).
Now issue is, during that process "event" is used on multiple occasions and previously event used to come from the click that user used to do TO start the process. now as I am running it as headless client, there are no clicks so how to handle that "event" parameter?

1) event.getFormName() is used in my process. but when there is no triggering event, how am I suppose to create the same effect so the process can run without drastic changes.
2) I tried creating JSEvent but obviously that will not have the properties, it will be a null event.

Please let me know if I am not clear or if I am missing a basic point, I am only 3 months experienced with Servoy. I will explain this more if required.
Thank you.
Talha,
Servoy Developer.
Servoy version 5.2.11
sabbatarian7
 
Posts: 4
Joined: Wed Feb 24, 2016 8:25 am

Re: Handling "Event" Parameter when running as Headless Clie

Postby mboegem » Tue May 03, 2016 12:11 pm

Hi sabbatarian7,

first of all welcome to the forum since this is your first post.

Your point is clear, you are breaking a pretty essential design rule: keep business logic and UI separated.
Of course there are situations where you need code depending on specific actions on the form and/or elements, but this should always be code in private functions.

Besides when you are using a headless client, be aware that it can not use forms (or at least the UI part of it)
Essentially all code executed within the headless client should be from functions in your top level scopes (ie. globals)

So take out the business logic from the code you're working on and use this in your headless client.
This should be possible, however hard to explain since we don't know the exact usecase.

Nevertheless: Hope this is pointing you in the right direction.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1382
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: Handling "Event" Parameter when running as Headless Clie

Postby sabbatarian7 » Wed May 04, 2016 6:41 am

Marc,

I completely understand your solution, But I can't extract out the process completely into top level scopes (globals) because it is too complex and dependent on multiple forms, So I guess I will have to carefully handle the places where the UI is affected.

I was thinking about using "isBatchProcess" check by having batch Process arguments as true. You already cleared almost all of it just can you verify that "isBatchProcess" will be right approach? Or is there anything better than that in servoy?

Example:
if (isBatchProcess)
{
//save withour any UI changes
}
else
{
//UI changes then save
}
Talha,
Servoy Developer.
Servoy version 5.2.11
sabbatarian7
 
Posts: 4
Joined: Wed Feb 24, 2016 8:25 am

Re: Handling "Event" Parameter when running as Headless Clie

Postby swingman » Wed May 04, 2016 7:26 am

Hi, I would extract as much as possible of the logic and put it into a (global) scope or an entity scope, passing JSRecords as parameters.
Code: Select all
{JSRecord<db:/yourdbname/yourtablenamehere>}

Then rebuild the functionality of the UI using these functions. The code in the UI will become much shorter, reusing the elements needed by the batch processor.

This way you can debug and check the logic in the Developer, which is much much easier than trying to work out what is happening in a headless client.

Hope this helps,
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1159
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 1 guest