Class 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 MODAL dialog eliminates much of the workflow complication involved when using the WWindow component.

    The content of the dialog is held in a WNamingContext with 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
    • 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.
        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.
        Parameters:
        mode - the dialog mode; MODAL or MODELESS.
      • getMode

        public int getMode()
        Returns the relationship of the dialog to the parent window.
        Returns:
        MODAL or MODELESS.
      • 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, using MessageFormat syntax.
        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:
        handleRequest in interface WComponent
        Overrides:
        handleRequest in class AbstractWComponent
        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:
        preparePaintComponent in class AbstractWComponent
        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:
        getChildCount in interface Container
        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:
        getChildAt in interface Container
        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:
        getIndexOfChild in interface Container
        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: Container
        Retrieves a list of this Container's.
        Specified by:
        getChildren in interface Container
        Returns:
        an immutable list of this Container.
      • toString

        public String toString()
        Description copied from class: AbstractWComponent
        Creates a String representation of this component; usually for debugging purposes.
        Overrides:
        toString in class AbstractWComponent
        Returns:
        a String representation of this component, for debugging purposes.
      • 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:
        getComponentModel in class AbstractWComponent
        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:
        getOrCreateComponentModel in class AbstractWComponent
        Returns:
        the model for this component