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
- Direct Known Subclasses:
DialogWindow
ModalDialog
but it doesn't have the same functions, e.g. initial height,
resizable and more. Since the CMS uses these functions, we need to keep it until the dialog system is refactored.
See DialogWindow
that extends ModalWindow
and
DialogService
that extends DialogWindow
.
#############################################
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
- a component - you need to add the component to modal window (with id obtained using
, orgetContentId()
- a page - you need to pass a
instance to aModalWindow.PageCreator
method.setPageCreator(PageCreator)
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
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
close(IPartialPageRequestHandler)
. If you want to be
notified when the window is closed (either using the close button or calling
setCloseButtonCallback(CloseButtonCallback)
, you can use
close(IPartialPageRequestHandler)
)
.
setWindowClosedCallback(WindowClosedCallback)
Title is specified using setTitle(String)
. Pass true
to
to use unencoded markup in the title.
Component.setEscapeModelStrings(boolean)
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).
specifies, whether the window can be resized.setResizable(boolean)
andsetInitialWidth(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 usingsetInitialHeight(int)
andsetWidthUnit(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 usesetHeightUnit(String)
.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
. If the name issetCookieName(String)
null
, position is not stored (initial width and height are always used). Default cookie name is null (position is not stored).
andsetMinimalWidth(int)
set the minimal dimensions of resizable window.setMinimalHeight(int)
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.setAutoSize(boolean)
- Modal window can chose between two colors of frame.
sets the dialog css class, possible values aresetCssClassName(String)
for blue frame andCSS_CLASS_BLUE
for gray frame.CSS_CLASS_GRAY
- Mask (element that prevents user from interacting the rest of the page) can be either
transparent or semitransparent.
alters this.setMaskType(MaskType)
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Deprecated.static interface
Deprecated.Callback for close button that contains a method that is invoked after the button has been clicked.static final class
Deprecated.Mask is the element behind the window, that prevents user from interacting the rest of page.static interface
Deprecated.Interface for lazy page creation.static interface
Deprecated.Callback called after the window has been closed. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Deprecated.the default id of the content componentstatic final String
Deprecated.CSS class for window with blue border.static final String
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
ConstructorDescriptionModalWindow
(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
Modifier and TypeMethodDescriptionvoid
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
Deprecated.Method that allows alternate script for closing the window.protected final org.apache.wicket.Component
Deprecated.Returns a content component.Deprecated.Returns the id of content component.Deprecated.Returns the name of cookie that is used to remember window position (and size if the window is resizable).Deprecated.Returns the CSS class name for this window.Deprecated.Retrns the CSS unit for initial window height.int
Deprecated.Returns the initial height of the window.int
Deprecated.Returns the initial width of the window.Deprecated.Returns the mask type of the windowint
Deprecated.Returns the minimal height of window (in pixels).int
Deprecated.Returns the minimal width of window (in pixels).protected CharSequence
Deprecated.Method that allows alternate script for showing the window.org.apache.wicket.model.IModel<String>
getTitle()
Deprecated.Returns the title of the window.Deprecated.Returns the CSS unit for initial window width.protected final String
Deprecated.Returns the javascript used to open the window.boolean
Deprecated.Returns whether window will be opened in autosize mode.protected boolean
Deprecated.Returns true if user has added own component to the window.boolean
Deprecated.Returns whether the window is resizable.boolean
isShown()
Deprecated.Is this window currently showing.boolean
Deprecated.Returns true if the initial height should be used (in favor of preserving real content height).protected boolean
Deprecated.You may subclass this method in case you don't want to show up the window on normal page refresh.protected ModalWindow.CloseButtonBehavior
Deprecated.Gives the possibility to provide customIAjaxCallListener
protected org.apache.wicket.request.resource.ResourceReference
Deprecated.Allows to override CSS contribution.protected void
Deprecated.protected void
onComponentTag
(org.apache.wicket.markup.ComponentTag tag) Deprecated.protected void
onDetach()
Deprecated.Detach the 'title' modelprotected void
postProcessSettings
(com.github.openjson.JSONObject settings) Deprecated.Method that allows tweaking the settingsremove
(org.apache.wicket.Component component) Deprecated.void
renderHead
(org.apache.wicket.markup.head.IHeaderResponse response) Deprecated.setAutoSize
(boolean autoSize) Deprecated.Sets whether window size will be automatically adjusted on opening to fit content's width and height.Deprecated.Sets the
instance.ModalWindow.CloseButtonCallback
setContent
(org.apache.wicket.Component component) Deprecated.Sets the content of the modal window.setCookieName
(String cookieName) Deprecated.Sets the name of the cookie that is used to remember window position (and size if the window is resizable).setCssClassName
(String cssClassName) Deprecated.Sets the CSS class name for this window.setHeightUnit
(String heightUnit) Deprecated.Sets the CSS unit used for initial window height.setInitialHeight
(int initialHeight) Deprecated.Sets the initial height of the window.setInitialWidth
(int initialWidth) Deprecated.Sets the initial width of the window.Deprecated.Sets the mask type of the window.setMinimalHeight
(int minimalHeight) Deprecated.Sets the minimal height of window.setMinimalWidth
(int minimalWidth) Deprecated.Sets the minimal width of window.setPageCreator
(ModalWindow.PageCreator creator) Deprecated.Sets the
instance.ModalWindow.PageCreator
setResizable
(boolean resizable) Deprecated.Sets whether the user will be able to resize the window.Deprecated.Sets the title of window.Deprecated.Sets the title of window.setUseInitialHeight
(boolean useInitialHeight) Deprecated.Sets whether to use initial height or preserve the real content height.setWidthUnit
(String widthUnit) Deprecated.Sets the CSS unit used for initial window width.Deprecated.Sets the@{link
instance.ModalWindow.WindowClosedCallback
void
show
(org.apache.wicket.core.request.handler.IPartialPageRequestHandler target) Deprecated.Shows the modal window.boolean
Deprecated.Returns whether the user should be asked before leaving the page.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, 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.wicket.IQueueRegion
dequeue, newDequeueContext
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
CSS_CLASS_BLUE
Deprecated.CSS class for window with blue border.- See Also:
-
CSS_CLASS_GRAY
Deprecated.CSS class for window with gray border.- See Also:
-
CONTENT_ID
Deprecated.the default id of the content component- See Also:
-
-
Constructor Details
-
ModalWindow
Deprecated.Creates a new modal window component.- Parameters:
id
- Id of component
-
ModalWindow
Deprecated.Creates a new modal window component.- Parameters:
id
- Id of componentmodel
- Model
-
-
Method Details
-
renderHead
public void renderHead(org.apache.wicket.markup.head.IHeaderResponse response) Deprecated.- Specified by:
renderHead
in interfaceorg.apache.wicket.markup.html.IHeaderContributor
- Overrides:
renderHead
in classorg.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:
-
isShown
public boolean isShown()Deprecated.Is this window currently showing.- Returns:
- the shown
-
setPageCreator
Deprecated.Sets the
instance. The instance is only used when no custom component has been added to the dialog.ModalWindow.PageCreator
- Parameters:
creator
-
instanceModalWindow.PageCreator
- Returns:
- this
-
setCloseButtonCallback
Deprecated.Sets the
instance.ModalWindow.CloseButtonCallback
- Parameters:
callback
- Callback instance- Returns:
- this
-
setWindowClosedCallback
Deprecated.Sets the@{link
instance.ModalWindow.WindowClosedCallback
- Parameters:
callback
- Callback instance- Returns:
- this
-
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 theclose(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
Deprecated.Method that allows alternate script for showing the window.- Returns:
- the script that actually shows the window.
-
getCloseJavacript
Deprecated.Method that allows alternate script for closing the window.- Returns:
- the script that actually closes the window.
-
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
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
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
-
setCssClassName
Deprecated.Sets the CSS class name for this window. This class affects the look of window frame. Possible values (if you don't make your style sheet) are
andCSS_CLASS_BLUE
.CSS_CLASS_GRAY
- Parameters:
cssClassName
-- Returns:
- this
- See Also:
-
getCssClassName
Deprecated.Returns the CSS class name for this window.- Returns:
- CSS class name
-
setInitialWidth
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 usingsetWidthUnit(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
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 usingsetHeightUnit(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
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
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
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
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
Deprecated.Returns the CSS unit for initial window width.- Returns:
- CSS unit for initial window width.
-
setHeightUnit
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
Deprecated.Retrns the CSS unit for initial window height.- Returns:
- CSS unit for initial window height.
-
setCookieName
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
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
Deprecated.Sets the title of window. If the window is a page, title can benull
. In that case it will display the title document inside the window.- Parameters:
title
- Title of the window- Returns:
- this
-
setTitle
Deprecated.Sets the title of window. If the window is a page, title can benull
. In that case it will display the title document inside the window.- Parameters:
title
- Title of the window- Returns:
- this
-
getTitle
Deprecated.Returns the title of the window.- Returns:
- Title of the window
-
setMaskType
Deprecated.Sets the mask type of the window.- Parameters:
mask
- The mask type- Returns:
- this
-
getMaskType
Deprecated.Returns the mask type of the window- Returns:
- The mask type
-
onBeforeRender
protected void onBeforeRender()Deprecated.- Overrides:
onBeforeRender
in classorg.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 classorg.apache.wicket.Component
- See Also:
-
Component.onComponentTag(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
Deprecated.- Overrides:
remove
in classorg.apache.wicket.MarkupContainer
- See Also:
-
MarkupContainer.remove(Component)
-
setContent
Deprecated.Sets the content of the modal window.- Parameters:
component
-- Returns:
- this;
-
getWindowOpenJavaScript
Deprecated.Returns the javascript used to open the window. SubclasspostProcessSettings(JSONObject)
to modify the JavaScript if needed. See WICKET-12- Returns:
- javascript that opens the window
-
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 classorg.apache.wicket.MarkupContainer
- See Also:
-
Component.onDetach()
-
setAutoSize
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
-
newCloseButtonBehavior
Deprecated.Gives the possibility to provide customIAjaxCallListener
- Returns:
- the behavior that should be used for the window close button
-
ModalDialog
instead