Class WDialog
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WDialog
-
- All Implemented Interfaces:
Container,WComponent,WebComponent,Serializable
public class WDialog extends AbstractWComponent implements Container
WDialog is used to display pop-up content. It uses theme and skin features which keep the dialog associated with its parent window. Using a
MODALdialog eliminates much of the workflow complication involved when using theWWindowcomponent.The content of the dialog is held in a
WNamingContextwith an id of "dlg" to make the ids of the content unique and have the same id prefix.- Since:
- 1.0.0
- Author:
- Christina Harris, Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWDialog.DialogModelHolds the state information of a WDialog.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
Fields Modifier and Type Field Description static intACTIVE_STATEThis state is when the dialog is open and the initial render of the content is complete.static intINACTIVE_STATEThis is the "normal" state for the Dialog component, when the dialog is not visible.static intMANUAL_OPEN_STATEThis state is when the dialog has been manually requested to open.static intMODALIn this mode the dialog retains the input focus while open.static intMODELESSIn this mode the dialog displays even when the user switches input focus to the window.static StringOPEN_DIALOG_ACTIONAction command string for opening dialog via AJAX.-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WDialog()Creates a WDialog.WDialog(WComponent content)Creates a WDialog containing the given content.WDialog(WComponent content, WButton trigger)Deprecated.1.2.3 useWDialog(WComponent)andsetTrigger(DialogOpenTrigger)instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddisplay()Signals that the dialog should be opened.WComponentgetChildAt(int index)Retrieves a child component by its index.intgetChildCount()List<WComponent>getChildren()Retrieves a list of this Container's.protected WDialog.DialogModelgetComponentModel()Returns the effective component model for this component.WComponentgetContent()intgetHeight()intgetIndexOfChild(WComponent childComponent)Retrieves the index of the given child.intgetMode()Returns the relationship of the dialog to the parent window.protected WDialog.DialogModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.intgetState()Retrieves the state of the dialog in the given context.StringgetTitle()DialogOpenTriggergetTrigger()ActiongetTriggerOpenAction()The action used when a dialog is opened via its trigger.intgetWidth()voidhandleRequest(Request request)Override handleRequest in order to perform processing specific to this component.protected voidhandleTriggerOpenAction(Request request)Run the trigger open action.booleanhasLegacyTriggerButton()Deprecated.1.2.3 for backwards compatibility only.booleanisAjaxTargeted()Indicates whether the dialog is currently the target of an AJAX operation.booleanisResizable()Deprecated.1.2.0 as dialogs must always be resizeable.protected WDialog.DialogModelnewComponentModel()Creates a new component model.protected voidpreparePaintComponent(Request request)Subclasses may override this method to place the component in the correct state before it is painted.voidsetContent(WComponent content)Set the WComponent which will handle the content for this dialog.voidsetHeight(int height)Sets the dialog height.voidsetMode(int mode)Set the relationship of the dialog to the parent window.voidsetResizable(boolean resizable)Deprecated.1.2.0 as dialogs must always be resizeable.voidsetTitle(String title, Serializable... args)Sets the dialog title.voidsetTrigger(DialogOpenTrigger trigger)Set the component which will open the WDialog.voidsetTriggerOpenAction(Action action)The action used when a dialog is opened via its trigger.voidsetWidth(int width)Sets the dialog width.StringtoString()Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Field Detail
-
INACTIVE_STATE
public static final int INACTIVE_STATE
This is the "normal" state for the Dialog component, when the dialog is not visible.- See Also:
- Constant Field Values
-
MANUAL_OPEN_STATE
public static final int MANUAL_OPEN_STATE
This state is when the dialog has been manually requested to open.- See Also:
- Constant Field Values
-
ACTIVE_STATE
public static final int ACTIVE_STATE
This state is when the dialog is open and the initial render of the content is complete.- See Also:
- Constant Field Values
-
MODAL
public static final int MODAL
In this mode the dialog retains the input focus while open. The user cannot switch windows until the dialog box is closed.- See Also:
- Constant Field Values
-
MODELESS
public static final int MODELESS
In this mode the dialog displays even when the user switches input focus to the window.- See Also:
- Constant Field Values
-
OPEN_DIALOG_ACTION
public static final String OPEN_DIALOG_ACTION
Action command string for opening dialog via AJAX.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WDialog
public WDialog()
Creates a WDialog.
-
WDialog
public WDialog(WComponent content)
Creates a WDialog containing the given content.- Parameters:
content- the dialog content.
-
WDialog
public WDialog(WComponent content, WButton trigger)
Deprecated.1.2.3 useWDialog(WComponent)andsetTrigger(DialogOpenTrigger)instead.Creates a WDialog containing the given content and trigger. The dialog will be opened client-side, without a round-trip.- Parameters:
content- the dialog content.trigger- the WButton used to trigger the dialog to display.
-
-
Method Detail
-
hasLegacyTriggerButton
public final boolean hasLegacyTriggerButton()
Deprecated.1.2.3 for backwards compatibility only.- Returns:
- true if the AjaxTrigger a WButton added via the deprecated constructor
- Since:
- 1.2.3
-
setContent
public void setContent(WComponent content)
Set the WComponent which will handle the content for this dialog.- Parameters:
content- the dialog content.
-
getContent
public WComponent getContent()
- Returns:
- the WComponent that handles the content for this dialog.
-
display
public void display()
Signals that the dialog should be opened.
-
getHeight
public int getHeight()
- Returns:
- The height of the dialog. The default is unspecified and therefore the dialog will autosize to fit its content or the viewport, whichever is smaller.
-
setHeight
public void setHeight(int height)
Sets the dialog height. A value of <=0 means "unspecified". If not set the dialog will attempt to autosize to fit its content or the viewport, whichever is smaller.- Parameters:
height- The height of the dialog, in pixels.
-
getWidth
public int getWidth()
- Returns:
- The width of the dialog. The default is 800 pixels.
-
setWidth
public void setWidth(int width)
Sets the dialog width. A value of <=0 means "unspecified".- Parameters:
width- The width of the dialog, in pixels.
-
isResizable
public final boolean isResizable()
Deprecated.1.2.0 as dialogs must always be resizeable.Dialogs must always be resizeable in order to meet accessibility requirements. See #606.- Returns:
- true if the dialog is resizable.
-
setResizable
public final void setResizable(boolean resizable)
Deprecated.1.2.0 as dialogs must always be resizeable.Sets whether the dialog is resizable. Dialogs must always be resizeable in order to meet accessibility requirements. See #606.- Parameters:
resizable- true if the dialog should be resizable, false if not.
-
setMode
public void setMode(int mode)
Set the relationship of the dialog to the parent window.
-
getMode
public int getMode()
Returns the relationship of the dialog to the parent window.
-
getTitle
public String getTitle()
- Returns:
- the dialog title.
-
setTitle
public void setTitle(String title, Serializable... args)
Sets the dialog title.- Parameters:
title- the title to set, usingMessageFormatsyntax.args- optional arguments for the message format string.
-
setTrigger
public void setTrigger(DialogOpenTrigger trigger)
Set the component which will open the WDialog.- Parameters:
trigger- the WComponent which will open the dialog on click/change
-
getTrigger
public DialogOpenTrigger getTrigger()
- Returns:
- the trigger component for this dialog.
-
setTriggerOpenAction
public void setTriggerOpenAction(Action action)
The action used when a dialog is opened via its trigger.- Parameters:
action- the trigger open action
-
getTriggerOpenAction
public Action getTriggerOpenAction()
The action used when a dialog is opened via its trigger.- Returns:
- the trigger open action
-
handleRequest
public void handleRequest(Request request)
Override handleRequest in order to perform processing specific to this component.- Specified by:
handleRequestin interfaceWComponent- Overrides:
handleRequestin classAbstractWComponent- Parameters:
request- the request being responded to.
-
handleTriggerOpenAction
protected void handleTriggerOpenAction(Request request)
Run the trigger open action.- Parameters:
request- the request being processed
-
preparePaintComponent
protected void preparePaintComponent(Request request)
Subclasses may override this method to place the component in the correct state before it is painted. When overriding this method, it is good practice to also call the superclass implementation.- Overrides:
preparePaintComponentin classAbstractWComponent- Parameters:
request- the request being responded to.
-
isAjaxTargeted
public final boolean isAjaxTargeted()
Indicates whether the dialog is currently the target of an AJAX operation.- Returns:
- true if the dialog is currently AJAX targeted, otherwise false.
-
getState
public int getState()
Retrieves the state of the dialog in the given context.- Returns:
- the current state of the dialog.
-
getChildCount
public int getChildCount()
- Specified by:
getChildCountin interfaceContainer- Returns:
- the number of child components currently contained within this component.
-
getChildAt
public WComponent getChildAt(int index)
Retrieves a child component by its index.- Specified by:
getChildAtin interfaceContainer- Parameters:
index- the index of the child component to be retrieved.- Returns:
- the child component at the given index.
-
getIndexOfChild
public int getIndexOfChild(WComponent childComponent)
Retrieves the index of the given child.- Specified by:
getIndexOfChildin interfaceContainer- Parameters:
childComponent- the child component to retrieve the index for.- Returns:
- the index of the given child component, or -1 if the component is not a child of this component.
-
getChildren
public List<WComponent> getChildren()
Description copied from interface:ContainerRetrieves a list of this Container's.- Specified by:
getChildrenin interfaceContainer- Returns:
- an immutable list of this Container.
-
toString
public String toString()
Description copied from class:AbstractWComponentCreates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component, for debugging purposes.
-
newComponentModel
protected WDialog.DialogModel newComponentModel()
Creates a new component model.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new DialogModel.
-
getComponentModel
protected WDialog.DialogModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModelin classAbstractWComponent- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WDialog.DialogModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModelin classAbstractWComponent- Returns:
- the model for this component
-
-