smart client -> webclient

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?

Hi Harjo,

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.

Regards,

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.

Paul

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)

Regards.

aha! Continuations!

THAT"S interesting! never saw this.

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’)}

the only one I found in the slide is: alert = function(text){plugins.dialogs.showInfoDialog(‘Alert’,text,‘Ok’)}

Then you’re looking at the wrong slide :) That is slide 25, not 24.

Paul

:-) yes I know, saw that one too, but I dont know how to implement this in an existing method…

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…

Hi Paul,

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.

Thanks,

Hi, i could download it.

See attachment

Regards,

JavaScript Exert Webinar preso.odp (38.1 KB)

Hans Nieuwenhuis:
Hi, i could download it.

See attachment

Regards,

Hi Hans,

Thanks. Can you please, provide the doc or docx version. I don’t have OpenOffice with me and with MS Word, the file is not opening.

Thanks

I could download it but not open it with openoffice either…must be bad data by now.
Is it on the wiki anywhere?

Here is a pdf

JavaScript Exert Webinar preso.pdf (256 KB)

Hans Nieuwenhuis:
Here is a pdf

Thank you very much, Hans.

Hi All,

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

Thanks

Does anyone having any sample code snippet for the same?? Please, share, if anyone have any or any thought on the same.

Thanks,

If you want to know more about Continuations, have a look here: http://wiki.apache.org/cocoon/RhinoWithContinuations

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

Paul