Servoy 8.2 Smart Client vs NG Client issue: passing a form

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Servoy 8.2 Smart Client vs NG Client issue: passing a form

Postby swingman » Wed Oct 04, 2017 6:44 pm

Hi, take the following code:

Code: Select all
      var menu = plugins.window.createPopupMenu();
      menu.addMenuItem('Companies', scopes.nav.go_to_screen).methodArguments = [event, forms.companies_main];
      menu.addMenuItem('Contacts', scopes.nav.go_to_screen).methodArguments = [event, forms.contacts_main];
      menu.addSeparator();
...


and

Code: Select all
/**
* @param {Number} arg1
* @param {Number} arg2
* @param {Number} arg3
* @param {Number} arg4
* @param {Number} arg5
* @param {JSEvent} event
* @param {RuntimeForm} a_form
*
* @properties={typeid:24,uuid:"E28E8FD9-261D-4905-B35D-1014111A0266"}
*/
function go_to_screen(arg1, arg2, arg3, arg4, arg5, event, a_form) {
   a_form.controller.show();
   scopes.globals.setupRecordStatus(a_form);
}


I am deliberately using the actual form in the code, this way Servoy will show an error if I try to reference a form which does not exist.

This works fine in Smart Client, the form object is passed to the go_to_screen function. In NG Client, it looks like the form_name is passed instead of the form object.
So the above code has to be rewritten as:

Code: Select all
/**
* @param {Number} arg1
* @param {Number} arg2
* @param {Number} arg3
* @param {Number} arg4
* @param {Number} arg5
* @param {JSEvent} event
* @param {String|RuntimeForm} a_form
*
* @properties={typeid:24,uuid:"E28E8FD9-261D-4905-B35D-1014111A0266"}
*/
function go_to_screen(arg1, arg2, arg3, arg4, arg5, event, a_form) {
   if(application.getApplicationType() == APPLICATION_TYPES.SMART_CLIENT) {
      a_form.controller.show();      
   } else {
      forms[a_form].controller.show();
   }
   scopes.globals.setupRecordStatus(a_form);
}


to work. Not a big issue as it is easy to rewrite the code to make it work by passing the form name, but it meant my main-menu did not work at first in NG-client.

Can the NG-client handle objects like forms in parameters?
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: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Servoy 8.2 Smart Client vs NG Client issue: passing a fo

Postby Harjo » Thu Oct 05, 2017 10:46 am

In my opinion there should be no difference in coding the same stuff in smart-client and ng-client.
So my advice is, to report this into Servoy support system, with a reproducable sample.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Servoy 8.2 Smart Client vs NG Client issue: passing a fo

Postby mboegem » Thu Oct 05, 2017 11:54 am

I wouldn't recommend building your menu like that at all, neither in smart of NG (if the latter would even work :-) )
Each form reference you're using will result in Servoy caching the form already.

I don't know how many entries you do have in the menu, but seems to me that first time build of this menu could be pretty slow.
Just pass the name of the form and show it through the code you mentioned in the rewrite.

Code: Select all
forms[a_form].controller.show();
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Servoy 8.2 Smart Client vs NG Client issue: passing a fo

Postby swingman » Wed Oct 11, 2017 4:55 pm

Yes, passing them menu name makes the menu appear faster the ride time.

I wrote it like that because I wanted Servoy Developer to pick up if any forms where missing or form names were misspelt.
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: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Servoy 8.2 Smart Client vs NG Client issue: passing a fo

Postby mboegem » Wed Oct 11, 2017 9:01 pm

swingman wrote:I wrote it like that because I wanted Servoy Developer to pick up if any forms where missing or form names were misspelt.


Would be better to write unit-test to perform this check, or if you don't like the idea, use the solutionModel to validate the formname by creating a JSForm instance and see if that returns result.
A JSForm instance doesn't instantiate your form instance, so will be lightning fast :-)

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: Google [Bot] and 6 guests