Child pages
  • Windows and Dialogs
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

A Servoy Smart or Web Client always comes with a main window and programmatically new windows can be opened or dialogs can be shown on top of existing windows to 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 and all other windows associated with 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.

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.

Dialog definition

Dialogs are bound to a parent, being the main window or another window or dialog. A dialog is always on top of its parent and automatically close if their parent is closed. At the top of a hierarchy of dialogs, there is always one window, being either the main window that was automatically launched when launching the Client or an additional window opened at a later stage.

In the Smart Client a Dialog is similar to a Window, with the exceptions that it does not support maximize and minimize operations, on top of the general restrictions applied to dialogs (tied to a parent, always on top of their parent and automatically closed when the parent closes). While a dialog is always op top of it's parent, in the Smart Client the dialog window can be moved around independently and thus be located in such a position as to not overlap it's parent.

In the Web Client a Dialog is displayed inline in the browser window/tab that displays the window in the dialogs parent hierarchy.

Dialog modality

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. 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.

Ironing out the differences

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. application.createWindow(windowName, type, [parentWindow])

  2. application.getWindow([windowName])

The JSWindow object

plugin.windows
plugins.dialogs

Tips & Tricks

Getting the active window

The currentcontroller object is a pointer to the topmost Form in the active window and thus can be used to retrieve the active window: 

currentcontroller.getWindow()
Checking if a Form is visible in the UI

The controller object of a Form has two useful functions to check if the Form is included or visible in the UI:

controller.getWindow()

If controller.getWindow() returns null, the Form is not included in the UI  

controller.getFormContext() 

Traversing the Window hierarchy

When having a reference to a JSWindow instance, the .getParent() of the JSWindow object can be invoked to get the parent window. Returns null for the topmost window in the hierarchy

Controller.getFormContext() returns a JSDataSet with the context in which a  

Single Window Interface

Multi Window Interface

onhide event

currentcontroller vs controller

Windowing API

application.closeAllWindows()

application.createWindow()

application.getScreenHeight

application.getScreenWidth

application.getWindow

application.isFormIndialog

application.showForm???

application.setToolbarVisible

controller.getFormContext()

controller.getWindow()

controller.show([windowName])

controller.showRecords(data, [windowname])

JSWindow

plugins.window

  • No labels