...
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 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 , if run under Java 5, the modal dialog blocks will block all windows and dialogs, except the dialogs that are opened with the modal dialog not only the ones in it's parent hierarchy. The API See #Smart Client modal dialog behavior difference in Java 5 & Java 6 for more info.
In the Smart Client the call that shows the modal dialog is blocking, meaning that it will not return continue 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 the 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 limited support for usage in the Servoy Web Client.
Due to limitations in Java 5 with regards to the modality API of windows and dialogs, a modal dialog in the Smart Client that runs under Java 5 will block ALL windows and dialogs, whereas when running under Java 6 the modal dialog will only block the dialogs and the window in its parent hierarchy.
Through the Smart Client settings on the Servoy Admin page, it's possible to restrict Smart Client to only run on Java 6 (or higher, although Java 6 has not been released yet). See Smart Client Settings for more information on specifying the min/max Java version for Smart Clients.
As can be seen described in the introduction above, there are differences between the Smart Client and the Web Client when it comes to Windows and Dialogs:
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. For the time being, the differences in items 3 & 4 can be ironed out.
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 2 solutions possible:
For item 4 the solution would be to use Forms diplayed as modal dialogs to mimic the functionality of the dialogs plugin, but this would be default have the same limitation mentioned under item 3. This could be countered using Continuations again.
The Continuations option is by far the most elegant solution and on ServoyForge there is a complete replacement for the dialogs plugin and the modal dialog API available in the form of a Servoy module that uses the Continuations API to provide the exact same behavior in the Smart and Web Client. To quote the project:
When using a dialog or a form in dialog being modal in web client then your method that opened this dialog doesn't wait until the (modal) dialog is closed like it would in Smart client.
This module solves this issue (using JavaScript Continuations) and is in fact a full dialog plugin replacement.
Apart from replacing the dialog plugin calls it provides a way to show modal form in dialogs that act the same way in web client.In short: when using this module your solution's dialogs and modal FID's are Web-client ready and work just the same in Smart-client.
The Dialogs module on ServoyForge is a drop-in replacement for the dialogs plugin that ships with Servoy and for the modal dialog API of Servoy.
The API for windows and dialogs is located in several locations
...
...
Each window and dialog, including the main window are instances of JSWindow. A reference to the JSWindow object can be retrieved in two ways:
Wiki Markup |
---|
application.createWindow(windowName, type, \[parentWindow\]) |
Wiki Markup |
---|
application.getWindow(\[windowName\]) |
The JSWindow object
...
...
...
...
...
The currentcontroller object is a pointer to the topmost Form in the active window and thus can be used to retrieve the active window:
Code Block |
---|
currentcontroller.getWindow()
|
...
...
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()
...
...
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
...
...
throughout the scripting API of Servoy:
Wiki Markup |
---|
controller.show(\[windowName\]) |
Wiki Markup |
---|
controller.showRecords(data, \[windowname\]) |
...
controller.getFormContext()
controller.getWindow()
...
...
...
Wiki Markup |
---|
controller.showRecords(data, \[windowname\]) |
JSWindow
...