|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WCompositeWidget
eu.webtoolkit.jwt.WDialog
public class WDialog
A WDialog shows a dialog.
By default, the dialog is modal. A modal window blocks the user interface, and does not allow the user to interact with any other part of the user interface until the dialog is closed (this is enforced at the server side, so you may rely on this behavior).
A modal dialog can be instantiated synchronously or asynchronously. A non-modal dialog can only be instantiated asynchronously.
When using a dialog asynchronously, there is no API call that waits for the
dialog to be closed. Then, the usage is similar to instantiating any other
widget. The dialog may be closed by calling accept(), reject() or
done() (or connecting a
signal to one of these methods). This will hide the dialog and emit the
finished() signal, which you then can listen for
to process the dialog result and delete the dialog. Unlike other widgets, a
dialog does not need to be added to a parent widget, but is hidden by
default. You must use the method WWidget#show() or
setHidden(true) to show the dialog.
The synchronous use of a dialog involves a call to
exec() which will block (suspend
the thread) until the dialog window is closed, and return the dialog result.
Events within dialog are handled using a so-called recursive event loop.
Typically, an OK button will be connected to accept(), and in some cases a Cancel button to reject(). This solution has the drawback that it is not scalable to many
concurrent sessions, since for every session with a recursive event loop, a
thread is locked. In practical terms, this means it is only suitable for
software with restricted access or deployed on an intranet or extranet. This
functionality is only available on Servlet 3.0 compatible servlet containers.
Use setModal(false) to create a non-modal dialog. A non-modal dialog does not block the underlying user interface: the user must not first deal with the dialog before interacting with the rest of the user interface.
Contents for the dialog is defined by adding it to the
getContents() widget.
This dialog looks like this (using the standard look):
A simple custom dialog (default) |
A simple custom dialog (polished) |
A dialog has the Wt-dialog and Wt-outset style
classes. The look can be overridden using the following style class
selectors:
.Wt-dialog .titlebar : The title bar .Wt-dialog .body : The body (requires vertical padding 4px).
Note: For the dialog (or rather, the silkscreen covering the user interface below) to render properly in IE, the "html body" margin is set to 0 (if it wasn't already).
| Nested Class Summary | |
|---|---|
static class |
WDialog.DialogCode
The result of a modal dialog execution. |
| Constructor Summary | |
|---|---|
WDialog()
Constructs a WDialog with a given window title. |
|
WDialog(java.lang.CharSequence windowTitle)
Constructs a WDialog with a given window title. |
|
| Method Summary | |
|---|---|
void |
accept()
Closes the dialog, with result is Accepted. |
void |
done(WDialog.DialogCode result)
Stops the dialog. |
WDialog.DialogCode |
exec()
Executes the dialog in a recursive event loop. |
WDialog.DialogCode |
exec(WAnimation animation)
Executes the dialog in a recursive event loop. |
Signal1<WDialog.DialogCode> |
finished()
Signal emitted when the dialog is closed. |
WContainerWidget |
getContents()
Returns the dialog contents container. |
WDialog.DialogCode |
getResult()
Returns the result that was set for this dialog. |
WContainerWidget |
getTitleBar()
Returns the dialog title bar container. |
WString |
getWindowTitle()
Returns the dialog window title. |
boolean |
isClosable()
Returns whether the dialog can be closed. |
boolean |
isModal()
Returns whether the dialog is modal. |
boolean |
isResizable()
Returns whether the dialog has a resize handle. |
boolean |
isTitleBarEnabled()
Returns whether the title bar is enabled. |
void |
positionAt(WWidget widget,
Orientation orientation)
Positions a widget next to another widget. |
void |
reject()
Closes the dialog, with result is Rejected. |
void |
rejectWhenEscapePressed()
Lets pressing the escape key reject the dialog. |
void |
remove()
Destructs a WDialog. |
void |
setClosable(boolean closable)
Adds a close button to the titlebar. |
void |
setHidden(boolean hidden,
WAnimation animation)
Hides or shows the widget. |
void |
setModal(boolean modal)
Sets whether the dialog is modal. |
void |
setResizable(boolean resizable)
Adds a resize handle to the dialog. |
void |
setTitleBarEnabled(boolean enable)
Enables or disables the title bar. |
void |
setWindowTitle(java.lang.CharSequence windowTitle)
Sets the dialog window title. |
| Methods inherited from class eu.webtoolkit.jwt.WWidget |
|---|
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getObjectName, setObjectName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WDialog(java.lang.CharSequence windowTitle)
Only a single Dialog may be constructed at any time. Unlike other widgets, a dialog does not need to be added to a container widget.
public WDialog()
Calls this(new WString())
| Method Detail |
|---|
public void remove()
remove in class WCompositeWidgetWContainerWidget.removeWidget(WWidget widget)public void setWindowTitle(java.lang.CharSequence windowTitle)
The window title is displayed in the title bar.
setTitleBarEnabled(boolean enable)public WString getWindowTitle()
setWindowTitle(CharSequence windowTitle)public void setTitleBarEnabled(boolean enable)
The titlebar is enabled by default.
public boolean isTitleBarEnabled()
setTitleBarEnabled(boolean enable)public WContainerWidget getTitleBar()
The title bar contains a single text that contains the caption. You may customize the title bar by for example adding other content.
public WContainerWidget getContents()
Content to the dialog window may be added to this container widget.
public WDialog.DialogCode exec(WAnimation animation)
Executes the dialog synchronously. This blocks the current thread of
execution until one of done(), accept() or reject() is called.
Warning: using exec() does
not scale to many concurrent sessions, since the thread is locked.
This functionality is only available on Servlet 3.0 compatible servlet containers.
done(WDialog.DialogCode result),
accept(),
reject()public final WDialog.DialogCode exec()
Returns exec(new WAnimation())
public void done(WDialog.DialogCode result)
Sets the dialog result, and emits the finished() signal.
finished(),
getResult()public void accept()
done(WDialog.DialogCode result),
reject()public void reject()
done(WDialog.DialogCode result),
accept()public void rejectWhenEscapePressed()
Before JWt 3.1.5, pressing escape automatically rejected the dialog. Since 3.1.4 this behaviour is no longer the default since it may interfere with other functionality in the dialog. Use this method to enable this behaviour.
reject()public Signal1<WDialog.DialogCode> finished()
done(WDialog.DialogCode result),
accept(),
reject()public WDialog.DialogCode getResult()
done(WDialog.DialogCode result)public void setModal(boolean modal)
A modal dialog will block the underlying user interface. A modal dialog can be shown synchronously or asynchronously. A non-modal dialog can only be shown asynchronously.
By default a dialog is modal.
public boolean isModal()
setModal(boolean modal)public void setResizable(boolean resizable)
The resize handle is shown in the bottom right corner of the dialog, and allows the user to resize the dialog (but not smaller than the content allows).
This also sets the minimum width and height to WLength.Auto to
use the initial width and height as minimum sizes. You may want to
provide other values for minimum width and height to allow the dialog to
be reduced in size.
WCompositeWidget.setMinimumSize(WLength width, WLength height),
WCompositeWidget.setMaximumSize(WLength width, WLength height)public boolean isResizable()
setResizable(boolean resizable)public void setClosable(boolean closable)
The close button is shown in the title bar. Clicking the close button will reject the dialog.
public boolean isClosable()
public void setHidden(boolean hidden,
WAnimation animation)
WWidget
Hides or show the widget (including all its descendant widgets). When
setting hidden = false, this widget and all
descendant widgets that are not hidden will be shown. A widget is only
visible if it and all its ancestors in the widget tree are visible, which
may be checked using isVisible().
setHidden in class WCompositeWidget
public void positionAt(WWidget widget,
Orientation orientation)
WWidget
Positions this absolutely positioned widget next to another
widget. Both widgets must be visible.
When orientation = Orientation.Vertical, the widget
is displayed below the other widget (or above in case there is not enough
room below). It is aligned so that the left edges align (or the right
edges if there is not enough room to the right).
Conversely, when orientation =
Orientation.Horizontal, the widget is displayed to the right of
the other widget (or to the left in case there is not enough room to the
right). It is aligned so that the top edges align (or the bottom edges if
there is not enough room below).
Note: This only works if JavaScript is available.
positionAt in class WWidget
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||