'force' argument in solution 'onClose' event

Questions, tips and tricks and techniques for scripting in Servoy

'force' argument in solution 'onClose' event

Postby mboegem » Wed Mar 10, 2010 5:15 pm

I was looking for a way to bypass a specific piece of code in my onClose method which is hooked up to my solutions 'onClose' event.
Having a closer look on default arguments (passed by Servoy) I ran into the 'force' argument which is passed to the method at the 'onClose' event.

I've tested with the code below, but either which way I close my application, the 'force' arguments keeps returning false.

Anyone any idea when this arguments will be true?

Code: Select all
/**
* Callback method for when solution is closed, force boolean argument tells if this is a force (not stopable) close or not.
*
* @param {Boolean} force if false then solution close can be stopped by returning false
*
* @returns {Boolean} allow close
*
* @properties={typeid:24,uuid:"9AA3BE5A-F1D0-4CE0-889A-1AF4D307FCAE"}
*/
function onSolutionClose(force)
{
   var $title = 'close';
   var $message = 'force? ' + force;
   var $button = 'ok';
   plugins.dialogs.showInfoDialog($title, $message, $button);
}


It would be really nice if this could be set to true when 'application.exit()' could take this as an argument as well.
This way you can have better control over the force argument I guess...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: 'force' argument in solution 'onClose' event

Postby pbakker » Wed Mar 10, 2010 6:09 pm

If the Client is closed from the Admin pages it will return true

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

Re: 'force' argument in solution 'onClose' event

Postby mboegem » Wed Mar 10, 2010 6:40 pm

Thnkx Paul,

could have thought of that myself :)

1) Would it be nice to have the 'force' option being triggered by an argument which can be added to application.exit() ??

2) Speaking of closing from the admin pages: often we need to request twice to have the client disconnected (mostly client that are idle for quite a while)
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: 'force' argument in solution 'onClose' event

Postby pbakker » Thu Mar 11, 2010 10:40 am

1) Would it be nice to have the 'force' option being triggered by an argument which can be added to application.exit() ??


You can already have a global var and read that in your onHide method and do something based on that. But, you could also register this as a feature request

2) Speaking of closing from the admin pages: often we need to request twice to have the client disconnected (mostly client that are idle for quite a while)

Registered this as case already?

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

Re: 'force' argument in solution 'onClose' event

Postby mboegem » Thu Mar 11, 2010 11:17 am

pbakker wrote: You can already have a global var and read that in your onHide method and do something based on that. But, you could also register this as a feature request


I guess I'll do both, I need it 'yesterday', but would be nice for the future :)

pbakker wrote:Registered this as case already?


I have to do some testing on this. Something crossed my mind and it could be my code is the cause of this... :?
If not I'll file a case and post the casenr. here

Thnkx so far!
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: 'force' argument in solution 'onClose' event

Postby mboegem » Thu Mar 11, 2010 5:55 pm

the double request we had to do on force closing of the client was caused by our code. :oops:
The code tried to show a confirmation dialog, which is not supported when you force close the client from the admin pages.

I bypassed the dialog when the 'force' argument is true and a single request is all I need :D
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: 'force' argument in solution 'onClose' event

Postby pbakker » Thu Mar 11, 2010 5:57 pm

Excellent tip, tnx for posting back!
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: 'force' argument in solution 'onClose' event

Postby jcompagner » Thu Mar 11, 2010 10:42 pm

mboegem wrote:the double request we had to do on force closing of the client was caused by our code. :oops:
The code tried to show a confirmation dialog, which is not supported when you force close the client from the admin pages.

I bypassed the dialog when the 'force' argument is true and a single request is all I need :D


that is a bug already fixed for 6
i will ask to backport this fix to 5.1

But showing a dialog that the user can say no to doesnt make much sense yes when it is forced...
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8884
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: 'force' argument in solution 'onClose' event

Postby mboegem » Fri Mar 12, 2010 9:18 am

jcompagner wrote:that is a bug already fixed for 6
i will ask to backport this fix to 5.1


Sure, very welcome!

jcompagner wrote:But showing a dialog that the user can say no to doesnt make much sense yes when it is forced...


That's true, but closing a client from the admin pages when the client wants to show a dialog as defined in the onClose method results in an error.
Error is something like 'dialog not supported in a non swing environment'.
This is where the duplicate close request was needed, the first request pops up this error, the second request just overrules this error...

I needed the code to bypass anyway, as I needed to introduce and test a global var 'forceClose' as well.
When we call application.exit(), this is in fact a 'force close' from our solution, which may not be canceled by a users dialog...
Made a feat. request for this: #279427

Thnkx for your response Johan!
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: 'force' argument in solution 'onClose' event

Postby martinh » Tue Mar 16, 2010 1:28 pm

mboegem wrote:That's true, but closing a client from the admin pages when the client wants to show a dialog as defined in the onClose method results in an error.
Error is something like 'dialog not supported in a non swing environment'.


Hi Marc,

This errormessage has been fixed already (case #273829) and will be available in the next release

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: 'force' argument in solution 'onClose' event

Postby martinh » Tue Mar 16, 2010 1:30 pm

jcompagner wrote:that is a bug already fixed for 6
i will ask to backport this fix to 5.1



Version 6 already. You guys are going much too fast .... :)
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium


Return to Methods

Who is online

Users browsing this forum: No registered users and 2 guests