Class ModalWindow

  • All Implemented Interfaces:
    Serializable, Iterable<org.apache.wicket.Component>, org.apache.wicket.event.IEventSink, org.apache.wicket.event.IEventSource, org.apache.wicket.feedback.IFeedbackContributor, org.apache.wicket.IConverterLocator, org.apache.wicket.IMetadataContext<Serializable,​org.apache.wicket.Component>, org.apache.wicket.IQueueRegion, org.apache.wicket.markup.html.IHeaderContributor, org.apache.wicket.request.component.IRequestableComponent, org.apache.wicket.util.IHierarchical<org.apache.wicket.Component>, org.apache.wicket.util.io.IClusterable

    public class ModalWindow
    extends org.apache.wicket.markup.html.panel.Panel
    Deprecated.
    use ModalDialog instead
    Modal window component.

    Modal window is a draggable window (with either <div> when used with a Panel or <iframe> when used with a Page content) that prevent user from interacting the rest of page (using a mask) until the window is closed.

    If you want this to work under IE, don't attach this component to a <span> tag, make sure you use a <div>.

    The window is draggable and optionally resizable. The content can be either

    In case the content is a component, it is not rendered until the window is shown (method show(IPartialPageRequestHandler)). The window can be made visible from an ajax handler using show(IPartialPageRequestHandler).

    To close the window there are multiple options. Static method close(IPartialPageRequestHandler) can be used to close the window from a handler of ajax link inside the window. By default the close button in the upper right corner of the window closes it. This behavior can be altered using setCloseButtonCallback(ModalWindow.CloseButtonCallback). If you want to be notified when the window is closed (either using the close button or calling close(IPartialPageRequestHandler)), you can use setWindowClosedCallback(ModalWindow.WindowClosedCallback).

    Title is specified using setTitle(String). Pass true to Component.setEscapeModelStrings(boolean) to use unencoded markup in the title.
    If the content is a page (iframe), the title can remain unset, in that case title from the page inside window will be shown.

    There are several options to specify the visual properties of the window. In all methods where size is expected, width refers to width of entire window (including frame), height refers to the height of window content (without frame).

    • setResizable(boolean) specifies, whether the window can be resized.
    • setInitialWidth(int) and setInitialHeight(int) specify the initial width and height of window. If the window is resizable, the unit of these dimensions is always "px". If the window is not resizable, the unit can be specified using setWidthUnit(String) and setHeightUnit(String). If the window is not resizable and the content is a component (not a page), the initial height value can be ignored and the actual height can be determined from the height of the content. To enable this behavior use setUseInitialHeight(boolean).
    • The window position (and size if the window is resizable) can be stored in a cookie, so that it is preserved when window is close. The name of the cookie is specified via setCookieName(String). If the name is null, position is not stored (initial width and height are always used). Default cookie name is null (position is not stored).
    • setMinimalWidth(int) and setMinimalHeight(int) set the minimal dimensions of resizable window.
    • setAutoSize(boolean) sets whether window size will be automatically adjusted on opening to fit content's width and height. Default is false. Doesn't work on IE 6.
    • Modal window can chose between two colors of frame. setCssClassName(String) sets the dialog css class, possible values are CSS_CLASS_BLUE for blue frame and CSS_CLASS_GRAY for gray frame.
    • Mask (element that prevents user from interacting the rest of the page) can be either transparent or semitransparent. setMaskType(ModalWindow.MaskType) alters this.
    Also it is recommended to put the modal window component in markup before any component (i.e. AjaxLink or AjaxButton) that shows it.

    If you want to use form in modal window component make sure that you put the modal window itself in another form (nesting forms is legal in Wicket) and that the form on modal window is submitted before the window get closed.

    Author:
    Matej Knopp
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String CONTENT_ID
      Deprecated.
      the default id of the content component
      static String CSS_CLASS_BLUE
      Deprecated.
      CSS class for window with blue border.
      static String CSS_CLASS_GRAY
      Deprecated.
      CSS class for window with gray border.
      • Fields inherited from class org.apache.wicket.markup.html.panel.Panel

        PANEL
      • Fields inherited from class org.apache.wicket.Component

        ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
    • Constructor Summary

      Constructors 
      Constructor Description
      ModalWindow​(String id)
      Deprecated.
      Creates a new modal window component.
      ModalWindow​(String id, org.apache.wicket.model.IModel<?> model)
      Deprecated.
      Creates a new modal window component.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void close​(org.apache.wicket.core.request.handler.IPartialPageRequestHandler target)
      Deprecated.
      Closes the modal window.
      static void closeCurrent​(org.apache.wicket.core.request.handler.IPartialPageRequestHandler target)
      Deprecated.
      Hides the modal window.
      protected String getCloseJavacript()
      Deprecated.
      Method that allows alternate script for closing the window.
      protected org.apache.wicket.Component getContent()
      Deprecated.
      Returns a content component.
      String getContentId()
      Deprecated.
      Returns the id of content component.
      String getCookieName()
      Deprecated.
      Returns the name of cookie that is used to remember window position (and size if the window is resizable).
      String getCssClassName()
      Deprecated.
      Returns the CSS class name for this window.
      String getHeightUnit()
      Deprecated.
      Retrns the CSS unit for initial window height.
      int getInitialHeight()
      Deprecated.
      Returns the initial height of the window.
      int getInitialWidth()
      Deprecated.
      Returns the initial width of the window.
      ModalWindow.MaskType getMaskType()
      Deprecated.
      Returns the mask type of the window
      int getMinimalHeight()
      Deprecated.
      Returns the minimal height of window (in pixels).
      int getMinimalWidth()
      Deprecated.
      Returns the minimal width of window (in pixels).
      protected CharSequence getShowJavaScript()
      Deprecated.
      Method that allows alternate script for showing the window.
      org.apache.wicket.model.IModel<String> getTitle()
      Deprecated.
      Returns the title of the window.
      String getWidthUnit()
      Deprecated.
      Returns the CSS unit for initial window width.
      protected String getWindowOpenJavaScript()
      Deprecated.
      Returns the javascript used to open the window.
      boolean isAutoSize()
      Deprecated.
      Returns whether window will be opened in autosize mode.
      protected boolean isCustomComponent()
      Deprecated.
      Returns true if user has added own component to the window.
      boolean isResizable()
      Deprecated.
      Returns whether the window is resizable.
      boolean isShown()
      Deprecated.
      Is this window currently showing.
      boolean isUseInitialHeight()
      Deprecated.
      Returns true if the initial height should be used (in favor of preserving real content height).
      protected boolean makeContentVisible()
      Deprecated.
      You may subclass this method in case you don't want to show up the window on normal page refresh.
      protected ModalWindow.CloseButtonBehavior newCloseButtonBehavior()
      Deprecated.
      Gives the possibility to provide custom IAjaxCallListener
      protected org.apache.wicket.request.resource.ResourceReference newCssResource()
      Deprecated.
      Allows to override CSS contribution.
      protected void onBeforeRender()
      Deprecated.
       
      protected void onComponentTag​(org.apache.wicket.markup.ComponentTag tag)
      Deprecated.
       
      protected void onDetach()
      Deprecated.
      Detach the 'title' model
      protected void postProcessSettings​(com.github.openjson.JSONObject settings)
      Deprecated.
      Method that allows tweaking the settings
      ModalWindow remove​(org.apache.wicket.Component component)
      Deprecated.
       
      void renderHead​(org.apache.wicket.markup.head.IHeaderResponse response)
      Deprecated.
       
      ModalWindow setAutoSize​(boolean autoSize)
      Deprecated.
      Sets whether window size will be automatically adjusted on opening to fit content's width and height.
      ModalWindow setCloseButtonCallback​(ModalWindow.CloseButtonCallback callback)
      Deprecated.
      ModalWindow setContent​(org.apache.wicket.Component component)
      Deprecated.
      Sets the content of the modal window.
      ModalWindow setCookieName​(String cookieName)
      Deprecated.
      Sets the name of the cookie that is used to remember window position (and size if the window is resizable).
      ModalWindow setCssClassName​(String cssClassName)
      Deprecated.
      Sets the CSS class name for this window.
      ModalWindow setHeightUnit​(String heightUnit)
      Deprecated.
      Sets the CSS unit used for initial window height.
      ModalWindow setInitialHeight​(int initialHeight)
      Deprecated.
      Sets the initial height of the window.
      ModalWindow setInitialWidth​(int initialWidth)
      Deprecated.
      Sets the initial width of the window.
      ModalWindow setMaskType​(ModalWindow.MaskType mask)
      Deprecated.
      Sets the mask type of the window.
      ModalWindow setMinimalHeight​(int minimalHeight)
      Deprecated.
      Sets the minimal height of window.
      ModalWindow setMinimalWidth​(int minimalWidth)
      Deprecated.
      Sets the minimal width of window.
      ModalWindow setPageCreator​(ModalWindow.PageCreator creator)
      Deprecated.
      Sets the ModalWindow.PageCreator instance.
      ModalWindow setResizable​(boolean resizable)
      Deprecated.
      Sets whether the user will be able to resize the window.
      ModalWindow setTitle​(String title)
      Deprecated.
      Sets the title of window.
      ModalWindow setTitle​(org.apache.wicket.model.IModel<String> title)
      Deprecated.
      Sets the title of window.
      ModalWindow setUseInitialHeight​(boolean useInitialHeight)
      Deprecated.
      Sets whether to use initial height or preserve the real content height.
      ModalWindow setWidthUnit​(String widthUnit)
      Deprecated.
      Sets the CSS unit used for initial window width.
      ModalWindow setWindowClosedCallback​(ModalWindow.WindowClosedCallback callback)
      Deprecated.
      Sets the @{link ModalWindow.WindowClosedCallback instance.
      void show​(org.apache.wicket.core.request.handler.IPartialPageRequestHandler target)
      Deprecated.
      Shows the modal window.
      boolean showUnloadConfirmation()
      Deprecated.
      Returns whether the user should be asked before leaving the page.
      ModalWindow showUnloadConfirmation​(boolean unloadConfirmation)
      Deprecated.
      Sets a flag whether to ask the user before leaving the page.
      • Methods inherited from class org.apache.wicket.markup.html.panel.Panel

        getRegionMarkup, newMarkupSourcingStrategy
      • Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer

        getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
      • Methods inherited from class org.apache.wicket.MarkupContainer

        add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onInitialize, onRender, queue, remove, removeAll, renderAll, renderAssociatedMarkup, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
      • Methods inherited from class org.apache.wicket.Component

        add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
      • Methods inherited from interface org.apache.wicket.IQueueRegion

        dequeue, newDequeueContext
    • Constructor Detail

      • ModalWindow

        public ModalWindow​(String id)
        Deprecated.
        Creates a new modal window component.
        Parameters:
        id - Id of component
      • ModalWindow

        public ModalWindow​(String id,
                           org.apache.wicket.model.IModel<?> model)
        Deprecated.
        Creates a new modal window component.
        Parameters:
        id - Id of component
        model - Model
    • Method Detail

      • renderHead

        public void renderHead​(org.apache.wicket.markup.head.IHeaderResponse response)
        Deprecated.
        Specified by:
        renderHead in interface org.apache.wicket.markup.html.IHeaderContributor
        Overrides:
        renderHead in class org.apache.wicket.Component
      • newCssResource

        protected org.apache.wicket.request.resource.ResourceReference newCssResource()
        Deprecated.
        Allows to override CSS contribution. Returning null means the CSS will be contributed via other sources, e.g. a global CSS resource.
        Returns:
        The CSS resource reference or null if CSS is contributed via other means.
        See Also:
        setCssClassName(String)
      • isShown

        public boolean isShown()
        Deprecated.
        Is this window currently showing.
        Returns:
        the shown
      • show

        public void show​(org.apache.wicket.core.request.handler.IPartialPageRequestHandler target)
        Deprecated.
        Shows the modal window.
        Parameters:
        target - Request target associated with current ajax request.
      • closeCurrent

        public static void closeCurrent​(org.apache.wicket.core.request.handler.IPartialPageRequestHandler target)
        Deprecated.
        Hides the modal window. This can be called from within the modal window, however, the modal window must have configured WindowClosedCallback. Otherwise use the close(IPartialPageRequestHandler) method.
        Parameters:
        target - Request target associated with current ajax request.
      • close

        public void close​(org.apache.wicket.core.request.handler.IPartialPageRequestHandler target)
        Deprecated.
        Closes the modal window.
        Parameters:
        target - Request target associated with current ajax request.
      • getShowJavaScript

        protected CharSequence getShowJavaScript()
        Deprecated.
        Method that allows alternate script for showing the window.
        Returns:
        the script that actually shows the window.
      • getCloseJavacript

        protected String getCloseJavacript()
        Deprecated.
        Method that allows alternate script for closing the window.
        Returns:
        the script that actually closes the window.
      • getContentId

        public String getContentId()
        Deprecated.
        Returns the id of content component.
         ModalWindow window = new ModalWindow(parent, "window");
         new MyPanel(window, window.getContentId());
         
        Returns:
        Id of content component.
      • setMinimalWidth

        public ModalWindow setMinimalWidth​(int minimalWidth)
        Deprecated.
        Sets the minimal width of window. This value is only used if the window is resizable. The width is specified in pixels and it is the width of entire window (including frame).
        Parameters:
        minimalWidth - Minimal window width.
        Returns:
        this
      • getMinimalWidth

        public int getMinimalWidth()
        Deprecated.
        Returns the minimal width of window (in pixels).
        Returns:
        Minimal width of window
      • setMinimalHeight

        public ModalWindow setMinimalHeight​(int minimalHeight)
        Deprecated.
        Sets the minimal height of window. This value is only used if window is resizable. The height is specified in pixels and it is the height of window content (without frame).
        Parameters:
        minimalHeight - Minimal height
        Returns:
        this
      • getMinimalHeight

        public int getMinimalHeight()
        Deprecated.
        Returns the minimal height of window (in pixels).
        Returns:
        Minimal height of window
      • getCssClassName

        public String getCssClassName()
        Deprecated.
        Returns the CSS class name for this window.
        Returns:
        CSS class name
      • setInitialWidth

        public ModalWindow setInitialWidth​(int initialWidth)
        Deprecated.
        Sets the initial width of the window. The width refers to the width of entire window (including frame). If the window is resizable, the width unit is always "px". If the window is not resizable, the unit can be specified using setWidthUnit(String). If cookie name is set and window is resizable, the initial width may be ignored in favor of width stored in cookie.
        Parameters:
        initialWidth - Initial width of the window
        Returns:
        this
      • getInitialWidth

        public int getInitialWidth()
        Deprecated.
        Returns the initial width of the window.
        Returns:
        Initial height of the window
      • setInitialHeight

        public ModalWindow setInitialHeight​(int initialHeight)
        Deprecated.
        Sets the initial height of the window. The height refers to the height of window content (without frame). If the window is resizable, the height unit is always "px". If the window is not resizable, the unit can be specified using setHeightUnit(String). If cookie name is set and window is resizable, the initial height may be ignored in favor of height stored in cookie.
        Parameters:
        initialHeight - Initial height of the window
        Returns:
        this
      • getInitialHeight

        public int getInitialHeight()
        Deprecated.
        Returns the initial height of the window.
        Returns:
        Initial height of the window
      • setUseInitialHeight

        public ModalWindow setUseInitialHeight​(boolean useInitialHeight)
        Deprecated.
        Sets whether to use initial height or preserve the real content height. This can only be used if the content is a component (not a page) and the window is not resizable.
        Parameters:
        useInitialHeight - Whether to use initial height instead of preserving content height instead of using initial height
        Returns:
        this
      • isUseInitialHeight

        public boolean isUseInitialHeight()
        Deprecated.
        Returns true if the initial height should be used (in favor of preserving real content height).
        Returns:
        True if initial height should be used, false is real content height should be preserved (valid only if the window is not resizable and the content is a component (not a page)
      • setResizable

        public ModalWindow setResizable​(boolean resizable)
        Deprecated.
        Sets whether the user will be able to resize the window.
        Parameters:
        resizable - Whether the window is resizable
        Returns:
        this
      • isResizable

        public boolean isResizable()
        Deprecated.
        Returns whether the window is resizable.
        Returns:
        True if the window is resizable, false otherwise
      • showUnloadConfirmation

        public ModalWindow showUnloadConfirmation​(boolean unloadConfirmation)
        Deprecated.
        Sets a flag whether to ask the user before leaving the page.
        Parameters:
        unloadConfirmation - a flag whether to ask the user before leaving the page
        Returns:
        this instance, for chaining
      • showUnloadConfirmation

        public boolean showUnloadConfirmation()
        Deprecated.
        Returns whether the user should be asked before leaving the page.
        Returns:
        true if the user should be asked if the last action causes leaving the page, false otherwise
      • setWidthUnit

        public ModalWindow setWidthUnit​(String widthUnit)
        Deprecated.
        Sets the CSS unit used for initial window width. This is only applicable when the window is not resizable.
        Parameters:
        widthUnit - CSS unit for initial window width.
        Returns:
        this
      • getWidthUnit

        public String getWidthUnit()
        Deprecated.
        Returns the CSS unit for initial window width.
        Returns:
        CSS unit for initial window width.
      • setHeightUnit

        public ModalWindow setHeightUnit​(String heightUnit)
        Deprecated.
        Sets the CSS unit used for initial window height. This is only applicable when the window is not resizable.
        Parameters:
        heightUnit - CSS unit for initial window height.
        Returns:
        this
      • getHeightUnit

        public String getHeightUnit()
        Deprecated.
        Retrns the CSS unit for initial window height.
        Returns:
        CSS unit for initial window height.
      • setCookieName

        public ModalWindow setCookieName​(String cookieName)
        Deprecated.
        Sets the name of the cookie that is used to remember window position (and size if the window is resizable).
        Parameters:
        cookieName - Name of the cookie
        Returns:
        this
      • getCookieName

        public String getCookieName()
        Deprecated.
        Returns the name of cookie that is used to remember window position (and size if the window is resizable).
        Returns:
        Name of the cookie
      • setTitle

        public ModalWindow setTitle​(String title)
        Deprecated.
        Sets the title of window. If the window is a page, title can be null. In that case it will display the title document inside the window.
        Parameters:
        title - Title of the window
        Returns:
        this
      • setTitle

        public ModalWindow setTitle​(org.apache.wicket.model.IModel<String> title)
        Deprecated.
        Sets the title of window. If the window is a page, title can be null. In that case it will display the title document inside the window.
        Parameters:
        title - Title of the window
        Returns:
        this
      • getTitle

        public org.apache.wicket.model.IModel<StringgetTitle()
        Deprecated.
        Returns the title of the window.
        Returns:
        Title of the window
      • onBeforeRender

        protected void onBeforeRender()
        Deprecated.
        Overrides:
        onBeforeRender in class org.apache.wicket.Component
        See Also:
        Component.onBeforeRender()
      • makeContentVisible

        protected boolean makeContentVisible()
        Deprecated.
        You may subclass this method in case you don't want to show up the window on normal page refresh.
        Returns:
        true, if the window shall be shown
      • onComponentTag

        protected void onComponentTag​(org.apache.wicket.markup.ComponentTag tag)
        Deprecated.
        Overrides:
        onComponentTag in class org.apache.wicket.Component
        See Also:
        Component.onComponentTag(org.apache.wicket.markup.ComponentTag)
      • getContent

        protected final org.apache.wicket.Component getContent()
        Deprecated.
        Returns a content component. In case user haven't specified any content component, it returns an empty WebMarkupContainer.
        Returns:
        Content component
      • isCustomComponent

        protected boolean isCustomComponent()
        Deprecated.
        Returns true if user has added own component to the window.
        Returns:
        True if user has added own component to the window, false otherwise.
      • remove

        public ModalWindow remove​(org.apache.wicket.Component component)
        Deprecated.
        Overrides:
        remove in class org.apache.wicket.MarkupContainer
        See Also:
        MarkupContainer.remove(org.apache.wicket.Component)
      • setContent

        public ModalWindow setContent​(org.apache.wicket.Component component)
        Deprecated.
        Sets the content of the modal window.
        Parameters:
        component -
        Returns:
        this;
      • postProcessSettings

        protected void postProcessSettings​(com.github.openjson.JSONObject settings)
        Deprecated.
        Method that allows tweaking the settings
        Parameters:
        settings -
      • onDetach

        protected void onDetach()
        Deprecated.
        Detach the 'title' model
        Overrides:
        onDetach in class org.apache.wicket.MarkupContainer
        See Also:
        Component.onDetach()
      • setAutoSize

        public ModalWindow setAutoSize​(boolean autoSize)
        Deprecated.
        Sets whether window size will be automatically adjusted on opening to fit content's width and height. Doesn't work on IE 6.
        Parameters:
        autoSize - Whether window size will be automatically adjusted
        Returns:
        this
      • isAutoSize

        public boolean isAutoSize()
        Deprecated.
        Returns whether window will be opened in autosize mode.
        Returns:
        True if the window will be opened open in autosize mode, false otherwise