Any established workarounds for NG Client?

Forum to discuss the new web client version of Servoy.

Any established workarounds for NG Client?

Postby swingman » Wed Oct 04, 2017 4:12 pm

Hi all,

is there any resource showing how to deal with the various issues you come across when converting from Smart Client to NG-Client? I'm thinking of
showCalendar
showFileOpenDialog
showFileSaveDialog
setClipBoardContent
and the others which generate warnings when you set a project to 'NG-Client only'

Some of these are impossible to recreate in a browser, while others require thinking in a very different way.

Take the code to export a report as a text file: In the smart client you ask the user to specify a file to save the data in, you generate and save the data and maybe you open the resulting file.
On the web you would get the server to generate the file and send it to the browser as a download or to a new tab in your browser....
what is the quickest way to do that in Servoy?

Thanks,
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: Any established workarounds for NG Client?

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

I have found that NG-client does not like

Code: Select all
var win = application.createWindow("address_popup", JSWindow.WINDOW, null);
controller.show(win);


The window does not show. Making the window MODAL fixes this.

Code: Select all
var win = application.createWindow("address_popup", JSWindow.MODAL_DIALOG, null);
controller.show(win);
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: Any established workarounds for NG Client?

Postby swingman » Fri Oct 13, 2017 4:11 pm

In my series of discoveries:
Showing the Open File dialog in Smart Client:

Code: Select all
function import_something(event) {
     var file = plugins.file.showFileOpenDialog(1, null, false, new Array("txt", "txt"));
     //do your stuff
}


becomes

Code: Select all
function import_something(event) {
    plugins.file.showFileOpenDialog(1, null, false, new Array("txt", "txt"),import_deliveries_callback);
}

/**
*
* @param {Array<plugins.file.JSFile>} files
*/
function import_deliveries_callback(files) {
     if (files.length) {
         var file = files[0];
         //do your stuff
     }
}



in NG-client.
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: Any established workarounds for NG Client?

Postby swingman » Sun Oct 15, 2017 10:17 pm

setClipBoardContent equivalent in NG-Client:

Make a simple form with a text area and define a form variable to hold the text you'd want to put on the clipboard.

Use
Code: Select all
application.createWindow("clipboard_popup", JSWindow.MODAL_DIALOG, null);


to display the window as a modal dialog. Ask the user to do the copy-and-paste. That is as close as you can get in a web browser.

Why would I use setClipBoardContent in the first place? You can create an email in the users default email client by using

Code: Select all
application.showURL("mailto:" + to_email + "?subject=" + subject + "&body=" + some_message);   


This will fail if the message gets too long (I stop at 1,600 character to be safe) so asking the user to copy-and-paste is a fallback.
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


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 11 guests