|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.Component
org.apache.wicket.MarkupContainer
org.apache.wicket.markup.html.WebMarkupContainer
org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
org.apache.wicket.markup.html.panel.Panel
org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow
public class ModalWindow
Modal window component.
Modal window is a draggable window (with either div or iframe 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
getContentId()
, or
ModalWindow.PageCreator
instance to a
setPageCreator(ModalWindow.PageCreator)
method.
show(AjaxRequestTarget)
)
. In case the content is another page, you can set
the desired pagemap name using setPageMapName(String)
. Setting pagemap is
only needed when wicket multiwindow support is on.
The window can be made visible from an ajax handler using
.
show(AjaxRequestTarget)
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(AjaxRequestTarget)
. If you want to be
notified when the window is closed (either using the close button or calling
setCloseButtonCallback(ModalWindow.CloseButtonCallback)
, you can use
close(AjaxRequestTarget)
)
.
setWindowClosedCallback(ModalWindow.WindowClosedCallback)
Title is specified using setTitle(String)
. 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)
.
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.
setCssClassName(String)
sets the dialog css class, possible values are
CSS_CLASS_BLUE
for blue frame and CSS_CLASS_GRAY
for
gray frame.
setMaskType(ModalWindow.MaskType)
alters
this.
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.
IPageSettings.setAutomaticMultiWindowSupport(boolean)
,
Serialized FormNested Class Summary | |
---|---|
protected class |
ModalWindow.CloseButtonBehavior
|
static interface |
ModalWindow.CloseButtonCallback
Callback for close button that contains a method that is invoked after the button has been clicked. |
static class |
ModalWindow.MaskType
Mask is the element behind the window, that prevents user from interacting the rest of page. |
static interface |
ModalWindow.PageCreator
Interface for lazy page creation. |
static interface |
ModalWindow.WindowClosedCallback
Callback called after the window has been closed. |
Nested classes/interfaces inherited from class org.apache.wicket.Component |
---|
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor<T extends Component>, Component.VisibilityChange |
Field Summary | |
---|---|
static String |
CONTENT_ID
the default id of the content component |
static String |
CSS_CLASS_BLUE
CSS class for window with blue border. |
static String |
CSS_CLASS_GRAY
CSS class for window with gray border. |
Fields inherited from class org.apache.wicket.Component |
---|
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
ModalWindow(String id)
Creates a new modal window component. |
|
ModalWindow(String id,
IModel<?> model)
Creates a new modal window component. |
Method Summary | |
---|---|
void |
close(AjaxRequestTarget target)
Closes the modal window. |
static void |
closeCurrent(AjaxRequestTarget target)
Hides the modal window. |
protected String |
getCloseJavacript()
Method that allows alternate script for closing the window. |
protected Component |
getContent()
Returns a content component. |
String |
getContentId()
Returns the id of content component. |
String |
getCookieName()
Returns the name of cookie that is used to remember window position (and size if the window is resizable). |
String |
getCssClassName()
Returns the CSS class name for this window. |
String |
getHeightUnit()
Retrns the CSS unit for initial window height. |
int |
getInitialHeight()
Returns the initial height of the window. |
int |
getInitialWidth()
Returns the initial width of the window. |
ModalWindow.MaskType |
getMaskType()
Returns the mask type of the window |
int |
getMinimalHeight()
Returns the minimal height of window (in pixels). |
int |
getMinimalWidth()
Returns the minimal width of window (in pixels). |
String |
getPageMapName()
Returns the page map name. |
protected Object |
getShowJavascript()
Method that allows alternate script for showing the window. |
IModel<String> |
getTitle()
Returns the title of the window. |
String |
getWidthUnit()
Returns the CSS unit for initial window width. |
protected String |
getWindowOpenJavascript()
Returns the javascript used to open the window. |
protected boolean |
isCustomComponent()
Returns true if user has added own component to the window. |
boolean |
isResizable()
Returns whether the window is resizable. |
boolean |
isShown()
Is this window currently showing. |
boolean |
isUseInitialHeight()
Returns true if the initial height should be used (in favor of preserving real content height). |
protected boolean |
makeContentVisible()
You may subclass this method in case you don't want to show up the window on normal page refresh. |
protected ModalWindow.CloseButtonBehavior |
newCloseButtonBehavior()
Gives the possibility to provide custom IAjaxCallDecorator |
protected void |
onBeforeRender()
Called just before a component is rendered. |
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag. |
protected void |
onDetach()
Detach the 'title' model |
protected AppendingStringBuffer |
postProcessSettings(AppendingStringBuffer settings)
Method that allows tweaking the settings |
void |
remove(Component component)
|
ModalWindow |
setCloseButtonCallback(ModalWindow.CloseButtonCallback callback)
Sets the instance. |
ModalWindow |
setContent(Component component)
Sets the content of the modal window. |
ModalWindow |
setCookieName(String cookieName)
Sets the name of the cookie that is used to remember window position (and size if the window is resizable). |
ModalWindow |
setCssClassName(String cssClassName)
Sets the CSS class name for this window. |
ModalWindow |
setHeightUnit(String heightUnit)
Sets the CSS unit used for initial window height. |
ModalWindow |
setInitialHeight(int initialHeight)
Sets the initial height of the window. |
ModalWindow |
setInitialWidth(int initialWidth)
Sets the initial width of the window. |
ModalWindow |
setMaskType(ModalWindow.MaskType mask)
Sets the mask type of the window. |
ModalWindow |
setMinimalHeight(int minimalHeight)
Sets the minimal height of window. |
ModalWindow |
setMinimalWidth(int minimalWidth)
Sets the minimal width of window. |
ModalWindow |
setPageCreator(ModalWindow.PageCreator creator)
Sets the instance. |
ModalWindow |
setPageMapName(String pageMapName)
Sets the name of the page ma for the content page. |
ModalWindow |
setResizable(boolean resizable)
Sets whether the user will be able to resize the window. |
ModalWindow |
setTitle(IModel<String> title)
Sets the title of window. |
ModalWindow |
setTitle(String title)
Sets the title of window. |
ModalWindow |
setUseInitialHeight(boolean useInitialHeight)
Sets whether to use initial height or preserve the real content height. |
ModalWindow |
setWidthUnit(String widthUnit)
Sets the CSS unit used for initial window width. |
ModalWindow |
setWindowClosedCallback(ModalWindow.WindowClosedCallback callback)
Sets the @{link instance. |
void |
show(AjaxRequestTarget target)
Shows the modal window. |
Methods inherited from class org.apache.wicket.markup.html.panel.Panel |
---|
onComponentTagBody, renderHead |
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup |
---|
newHeaderPartContainer, renderHeadFromAssociatedMarkupFile |
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer |
---|
getMarkupType, getWebPage, getWebRequest |
Methods inherited from class org.apache.wicket.MarkupContainer |
---|
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onAfterRenderChildren, onRender, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, renderNext, replace, setDefaultModel, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String CSS_CLASS_BLUE
public static final String CSS_CLASS_GRAY
public static final String CONTENT_ID
Constructor Detail |
---|
public ModalWindow(String id)
id
- Id of componentpublic ModalWindow(String id, IModel<?> model)
id
- Id of componentmodel
- ModelMethod Detail |
---|
public boolean isShown()
public ModalWindow setPageMapName(String pageMapName)
pageMapName
- Name of the page map
public String getPageMapName()
public ModalWindow setPageCreator(ModalWindow.PageCreator creator)
ModalWindow.PageCreator
instance. The instance is only used when no custom
component has been added to the dialog.
creator
- ModalWindow.PageCreator
instance
public ModalWindow setCloseButtonCallback(ModalWindow.CloseButtonCallback callback)
ModalWindow.CloseButtonCallback
instance.
callback
- Callback instance
public ModalWindow setWindowClosedCallback(ModalWindow.WindowClosedCallback callback)
@{link ModalWindow.WindowClosedCallback
instance.
callback
- Callback instance
public void show(AjaxRequestTarget target)
target
- Request target associated with current ajax request.public static final void closeCurrent(AjaxRequestTarget target)
close(AjaxRequestTarget)
method.
target
- Request target associated with current ajax request.public void close(AjaxRequestTarget target)
target
- Request target associated with current ajax request.protected Object getShowJavascript()
protected String getCloseJavacript()
public String getContentId()
ModalWindow window = new ModalWindow(parent, "window"); new MyPanel(window, window.getContentId());
public ModalWindow setMinimalWidth(int minimalWidth)
minimalWidth
- Minimal window width.
public int getMinimalWidth()
public ModalWindow setMinimalHeight(int minimalHeight)
minimalHeight
- Minimal height
public int getMinimalHeight()
public ModalWindow setCssClassName(String cssClassName)
CSS_CLASS_BLUE
and CSS_CLASS_GRAY
.
cssClassName
-
public String getCssClassName()
public ModalWindow setInitialWidth(int initialWidth)
setWidthUnit(String)
. If cookie
name is set and window is resizable, the initial width may be ignored in favor of width
stored in cookie.
initialWidth
- Initial width of the window
public int getInitialWidth()
public ModalWindow setInitialHeight(int initialHeight)
setHeightUnit(String)
. If cookie name
is set and window is resizable, the initial height may be ignored in favor of height stored
in cookie.
initialHeight
- Initial height of the window
public int getInitialHeight()
public ModalWindow setUseInitialHeight(boolean useInitialHeight)
useInitialHeight
- Whether to use initial height instead of preserving content height instead of
using initial height
public boolean isUseInitialHeight()
public ModalWindow setResizable(boolean resizable)
resizable
- Whether the window is resizable
public boolean isResizable()
public ModalWindow setWidthUnit(String widthUnit)
widthUnit
- CSS unit for initial window width.
public String getWidthUnit()
public ModalWindow setHeightUnit(String heightUnit)
heightUnit
- CSS unit for initial window height.
public String getHeightUnit()
public ModalWindow setCookieName(String cookieName)
cookieName
- Name of the cookie
public String getCookieName()
public ModalWindow setTitle(String title)
null
. In that
case it will display the title document inside the window.
title
- Title of the window
public ModalWindow setTitle(IModel<String> title)
null
. In that
case it will display the title document inside the window.
title
- Title of the window
public IModel<String> getTitle()
public ModalWindow setMaskType(ModalWindow.MaskType mask)
mask
- The mask type
public ModalWindow.MaskType getMaskType()
protected void onBeforeRender()
Component
NOTE: If you override this, you *must* call super.onBeforeRender() within
your implementation.
Because this method is responsible for cascading Component.onBeforeRender()
call to its
children it is strongly recommended that super call is made at the end of the override.
onBeforeRender
in class Component
Component.onBeforeRender()
protected boolean makeContentVisible()
protected void onComponentTag(ComponentTag tag)
Component
onComponentTag
in class Panel
tag
- Tag to modifyPanel.onComponentTag(org.apache.wicket.markup.ComponentTag)
protected final Component getContent()
protected boolean isCustomComponent()
public void remove(Component component)
remove
in class MarkupContainer
component
- Component to remove from this containerMarkupContainer.remove(org.apache.wicket.Component)
public ModalWindow setContent(Component component)
component
-
protected final String getWindowOpenJavascript()
postProcessSettings(AppendingStringBuffer)
to modify the JavaScript if needed.
See WICKET-12
protected AppendingStringBuffer postProcessSettings(AppendingStringBuffer settings)
settings
-
protected void onDetach()
onDetach
in class Component
Component.onDetach()
protected ModalWindow.CloseButtonBehavior newCloseButtonBehavior()
IAjaxCallDecorator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |