Project

General

Profile

About v2.1

Description

This version of the busy plugin is web compatible, using jQuery and the jQuery-blockUI plugin for the Wicket counterpart of the Swing component.

NB This doc if for the version of the plugin compatible with Servoy 5.1.x and more...
For versions < 5.1, check this page

It has been tested on Windows and Mac OS X with Servoy 5.1.4 and 5.2 in developer/smart/web client.
It has been tested on IE and Firefox, so please report if you find any unknown problems with your platform/browser.

There are 4 methods you can use:
  • prepare()
  • block()
  • unblock()
  • isCanceled()

The prepare method is used in web client to put the necessary headers in the page
The block method is the one that starts the process. It takes a JS Object {} as parameter, which properties are almost all optional...
The unblock method will release the UI
The isCanceled method is here to check if the user canceled the process

Example of usage

First you need to initialize the plugin for web client in the pages you will use it, this is done in the onShow event, like so:

if (application.getApplicationType() == APPLICATION_TYPES.WEB_CLIENT) {
    plugins.busy.prepare();
}

Then you use the block() method like so:

function startBusy(theDialogName)
{
    var params = {
        processFunction: globals.process,
        message: 'Lengthy process... please wait!', 
        opacity: 0.5,
        paneColor: '#000000',
        textColor: '#FF0000',
        showCancelButton: true,
        cancelButtonText: 'Stop this!',
        dialogName = theDialogName,
        fontType: 'Courier New,3,32',
        processArgs: [1, true, 'whatever']
    };
    plugins.busy.block( params );
}

and then later, in your process method you simply unblock() to release the GUI:

        plugins.busy.unblock();

Download the sample solution for example of usage, with parameters, in the main frame or dialogs.
There is one available for 3.5.x and one for 4.1.x/5.x

Available parameters

  • processFunction: mandatory - the function (without parenthesis) that will contains the 'lengthy' process
  • dialogName: (mandatory if called from a dialog) the name of the dialog
  • message: the message to show (optional, i18n compatible, default=null)
  • opacity: a float value (0..1), where 0=transparent, 1=opaque (optional, default=0.5)
  • paneColor: a color value, (optional, default=black='#000000')
  • textColor: a color value, (optional, default=black='#FFFFFF')
  • showCancelButton: shows a cancel button which will trigger the callback function (optional, default=false)
  • cancelButtonText: text of the cancel button (optional, i18n compatible, default='Cancel')
  • callBackFunction: a function used for callback when using the cancel button (optional, default=null)
  • fontType: a String, allows to set the font of the message (uses the same syntax as the solutionModel fontType property) - compatible web client, provided the font exists on the client platform.
  • processArgs: an Array that can be passed to the process function

callBackFunction is not used anymore, it was primarily used to update a cancel boolean flag, which is now done directly in the plugin, so use isCanceled() in your process to check for cancelled state.

The process function

function process(integ, bool, str)
{
    application.updateUI();
    application.output("process started");

    // always put your process in a try/catch/finally block:
    try {
        // your long process in a loop:
        for (var i = 1; i < max; i++) {

            // do something here
            application.output(i);
            application.sleep(1000);

            // check for each iteration if the user has canceled:
            if (plugins.busy.isCanceled()) {
                application.output("process canceled");
                break;
            }
        }

    // trap any exception here (or throw)
    } catch (e) {
        application.output("exception caught");
        application.output(e);

    // always unblock in a finally block (this will always happen!)
    } finally {
        plugins.busy.unblock();
    }
    application.output("process end");

}