Child pages
  • Windows and Dialogs

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A Servoy Smart or Web Client always comes with a main window. Servoy offers support to open new windows or show dialogs to show display Forms.

Window definition

Windows are independent of each other and are only tied to the Client. Closing the Client will close all windows. When a Smart or Web Client is launched it will always open with a window, the so-called main window. Closing the main window will close the Client.

In the Smart Client each window occupies an entry on the system bar. The individual windows can be minimized, maximized and closed independently and can be moved in front of one another. TODO: validate this for OSX

In the Web Client a window can be either a separate browser window or an additional tab in the existing browser window, depending the type of browser and/or the browsers configuration. The usefulness of opening new windows in browsers however is limited, due to browser restrictions on opening new windows/tabs programmatically from within a page. Almost any browser nowadays comes out of the box with a popup blocker installed, preventing pages from automatically opening new windows/tabs.

...

Dialogs can be either modal or non-modal (also referred to as modeless). A modal dialog blocks access to all other dialogs and the window in it's parent hierarchy, whereas non-modal dialogs do not block the access.

In the Smart Client a modal dialog blocks all windows and dialogs, except the dialogs that are opened with the modal dialog in it's parent hierarchy. The API call that shows the modal dialog is blocking, meaning that it will not return until the modal dialog is closed. Only when the dialog is closed will the rest of the code in the function that showed the modal dialog be executed.

In the Web Client a modal dialog block its parent window and all dialogs in it's parent hierarchy TODO: validate this assumption

...

Dialog 

...

The main object involved when working with windows is the JSWindow object. Additionally there is the window plugin and the dialogs plugin.

Parenting

Development considerations

Smart Client vs. Web Client

JSWindow

...

. The API call that shows the modal dialog in non-blocking, meaning it will return immediately and the rest of the code in the function will continue to execute. 

In addition to the ability to open new windows and show dialogs displaying Forms, Servoy also comes with a Dialogs plugin to show standard dialogs. This plugin only has partial support for the Servoy Web Client.

Web Client compatibility

...

Differences

...

As can be seen in the introduction above, there are differences between the Smart Client and the Web Client when it comes to Windows and Dialogs:

  1. The Web Client supports opening new Windows, but most likely they will be blocked by a popup blocker
  2. Dialogs in the Web Client are displayed inline in the browser window/tab that displays the window at the top of the parent hierarchy of the dialog. Due to the fact that the dialog is shown inline, it cannot be moved in such a way that it doesn't overlap it's parent window.
  3. The API call to show a non-modal dialog is non-blocking
  4. The dialogs plugin only has partial support for the Web Client

The first two items in the above list are due to technical restrictions in the browser, where item 2 is a design decision based on the restriction mentioned under item 1. 
The reasons behind item 3 & 4 are of technical nature and are likely to be resolved in a future version of Servoy.

...

Solutions

...

The solution to item 1 & 2 is to not use windows in combination with the Web Client: due to the fact that popups were abused on the web, every browser now comes with popup blockers that are enabled by default. Due to this, the defacto standard for web applications in general is a single window interface.

For item 3 & 4 there are multiple solutions possible:

  • Make sure the API call to show the modal dialog is the last piece of code in the function. This is a straight forward solution, but can complicate the programming modal
  • Use dialogs displaying a custom form instead of the dialogs plugin
  • Use Continuations when running in the Web Client to simulate the blocking behavior seen in the Smart Client. This could be wrapped up in a module that provides a scripting API that uses Continuations when running in the Web Client and the native Servoy Scripting API when running in the Smart Client
    The later option is by far the most elegant solution.

API overview

The API for windows and dialogs is located in several locations

...

JSWindow

...

Each window and dialog, including the main window are instances of JSWindow. A reference to the JSWindow object can be retrieved in two ways:

  1. Wiki Markup
    application.createWindow(windowName, type, \[parentWindow\])
  2. Wiki Markup
    application.getWindow(\[windowName\])

The JSWindow object

...

plugin.windows

...

plugins.dialogs

...

Retrieving Window context in scripting

Dialogs

Window plugin

Single Window Interface

Multi Window InterfaceExecution flow in WC

onhide event

currentcontroller vs controller

...