We have a smart-client solution which we want to convert to webclient.
the solution is FULL of code like this:
var vAnswer = plugins.dialogs.showWarningDialog('i18n:1.warning', 'i18n:1.message.deleterecord', 'i18n:1.ok', 'i18n:1.cancel')
if (vAnswer == i18n.getI18NMessage('i18n:1.ok')) {
//do my stuff here
}
Also other plugins.dialogs, like INFO, ERROR are used a lot in the middle of large methods, which does not work in the webclient.
Before we start, what is the best, easiest & quickest way to convert such code to be webcomplaint?? Are there any tricks/tips?
In our framework ( built together with Servoy ) we now use a separate module
that displays dialogs using the solution model to create forms and formindialog to display them.
we replaced all calls to the dialog plugin with calls to this methods in this module.
And now the dialogs are displayed in the same way in Web- and Smart client.
yes, I know that is possible, but you can’t just replace that single line of code, with the one build for webclient.
because in webclient you use FormInDialog right? and your method has to end with that showFormInDialog. right?
so that’s a LOT of work, to rework all those methods… Or there must be some simpler way
And don’t forget that in WC the code after the showFormInDialog continues to execute, so you must create a callback function to execute after the dialog close (if the code depends of the button pressed).
So yes a LOT of work…
It’s possible to get the same behavior in the Web Client for dialogs by utilizing so-called Continuations in scripting, see slide 24 of the JavaScript Expert webinar slides.
That is correct Paul and that is how our framework handles this.
So, if you have created the methods for the new dialogs it is simply a replace action.
plugins.dialogs… to svy_dialogs… ( the syntax is exactly the same in our framework)
Do you have some more examples on how to implement this?
the only one I found in the slide is: alert = function(text){plugins.dialogs.showInfoDialog(‘Alert’,text,‘Ok’)}
pbakker:
It’s possible to get the same behavior in the Web Client for dialogs by utilizing so-called Continuations in scripting, see slide 24 of the JavaScript Expert webinar slides.
Paul
Maybe some reference to this would be in the wiki or in the function documentation…
If we knew that before we wouldn´t have wasted hours refactoring the code…
pbakker:
It’s possible to get the same behavior in the Web Client for dialogs by utilizing so-called Continuations in scripting, see slide 24 of the JavaScript Expert webinar slides.
Paul
The above mentioned link is not working. Can you please, look in to the same.
I have tried with below code, according to the Slide #24 of document “JavaScript Expert webinar slides”, to suspend the current execution for a larger time in Web Client but, It didn’t worked. Can any one please, help me on the same?
// call to the Show form in Dialog
application.showFormInDialog(forms[formName], -1, -1, -1, -1, title);
// suspend the current execution
globals.cont = new Continuation();
new Packages.org.mozilla.javascript.continuations.Continuation()();
globals.cont();
// Do some other processing
It’s been a while since I looked at Continuations and everytime I look at them again, I need to think hard to understand exactly how they work, but looking at your example, I think the following is off:
1: globals.cont = new Continuation();
2: new Packages.org.mozilla.javascript.continuations.Continuation()();
3: globals.cont();
Line 1 captures the state of the exection stack into the globals variable cont.
Line 2 stops the execution of the current (stack of) method(s)
Line 3: because line 2 stopped the execution of the current (stack of) method(s), this line will not get executed.
Usually, line 1 & 2 go together in a method and line 3 is used to resume the execution of the execution stack captured in the global variable cont