Author: knopp
Date: Thu Sep 18 16:27:40 2008
New Revision: 696853
URL: http://svn.apache.org/viewvc?rev=696853&view=rev
Log:
WICKET-1120
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java?rev=696853&r1=696852&r2=696853&view=diff
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
(original)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
Thu Sep 18 16:27:40 2008
@@ -107,7 +107,7 @@
* transparent or semitransparent. <code>[EMAIL PROTECTED]
#setMaskType(ModalWindow.MaskType)}</code> alters
* this.
* </ul>
- *
+ *
* @see IPageSettings#setAutomaticMultiWindowSupport(boolean)
* @author Matej Knopp
*/
@@ -123,7 +123,7 @@
/**
* Creates a new modal window component.
- *
+ *
* @param id
* Id of component
*/
@@ -145,14 +145,14 @@
* just passing a page instance is that page created in <code>[EMAIL
PROTECTED] #createPage()}</code>
* will have the pagemap automatically set to the pagemap specified for
* <code>[EMAIL PROTECTED] ModalWindow}</code>.
- *
+ *
* @author Matej Knopp
*/
public static interface PageCreator extends IClusterable
{
/**
* Creates a new instance of content page.
- *
+ *
* @return new page instance
*/
public Page createPage();
@@ -163,7 +163,7 @@
* clicked. If no callback instance is specified using
* <code>[EMAIL PROTECTED]
#setCloseButtonCallback(ModalWindow.CloseButtonCallback)}</code>, no ajax
* request will be fired. Clicking the button will just close the
window.
- *
+ *
* @author Matej Knopp
*/
public static interface CloseButtonCallback extends IClusterable
@@ -171,10 +171,10 @@
/**
* Methods invoked after the button has been clicked. The
invocation is done using an ajax
* call, so <code>[EMAIL PROTECTED] AjaxRequestTarget}</code>
instance is available.
- *
+ *
* @param target
* <code>[EMAIL PROTECTED] AjaxRequestTarget}</code>
instance bound with the ajax request.
- *
+ *
* @return True if the window can be closed (will close the
window), false otherwise
*/
public boolean onCloseButtonClicked(AjaxRequestTarget target);
@@ -184,14 +184,14 @@
* Callback called after the window has been closed. If no callback
instance is specified using
* [EMAIL PROTECTED]
ModalWindow#setWindowClosedCallback(ModalWindow.WindowClosedCallback)}, no ajax
* request will be fired.
- *
+ *
* @author Matej Knopp
*/
public static interface WindowClosedCallback extends IClusterable
{
/**
* Called after the window has been closed.
- *
+ *
* @param target
* <code>[EMAIL PROTECTED] AjaxRequestTarget}</code>
instance bound with the ajax request.
*/
@@ -201,7 +201,7 @@
/**
* Is this window currently showing.
- *
+ *
* @return the shown
*/
public boolean isShown()
@@ -212,7 +212,7 @@
/**
* Sets the name of the page ma for the content page. This makes only
sense when the content is
* a page, not a component and if wicket multiwindow support is turned
on.
- *
+ *
* @param pageMapName
* Name of the page map
*/
@@ -223,7 +223,7 @@
/**
* Returns the page map name.
- *
+ *
* @return The page map name.
*/
public String getPageMapName()
@@ -234,19 +234,19 @@
/**
* Sets the <code>[EMAIL PROTECTED] PageCreator}</code> instance. The
instance is only used when no
* custom component has been added to the dialog.
- *
+ *
* @param creator
* <code>[EMAIL PROTECTED] PageCreator}</code> instance
*/
public void setPageCreator(PageCreator creator)
{
setContent(empty);
- pageCreator = creator;
+ pageCreator = creator;
}
/**
* Sets the <code>[EMAIL PROTECTED] CloseButtonCallback}</code>
instance.
- *
+ *
* @param callback
* Callback instance
*/
@@ -257,7 +257,7 @@
/**
* Sets the <code>@{link [EMAIL PROTECTED] WindowClosedCallback}</code>
instance.
- *
+ *
* @param callback
* Callback instance
*/
@@ -268,7 +268,7 @@
/**
* Shows the modal window.
- *
+ *
* @param target
* Request target associated with current ajax request.
*/
@@ -287,7 +287,7 @@
* Hides the modal window. This can be called from within the modal
window, however, the modal
* window must have configured WindowClosedCallback. Otherwise use the
* [EMAIL PROTECTED] #close(AjaxRequestTarget)} method.
- *
+ *
* @param target
* Request target associated with current ajax request.
*/
@@ -298,7 +298,7 @@
/**
* Closes the modal window.
- *
+ *
* @param target
* Request target associated with current ajax request.
*/
@@ -315,7 +315,8 @@
private static String getCloseJavacript()
{
return "var win;\n" //
- + "try {\n" + " win = window.parent.Wicket.Window;\n"
+ + "try {\n"
+ + " win = window.parent.Wicket.Window;\n"
+ "} catch (ignore) {\n"
+ "}\n"
+ "if (typeof(win) == \"undefined\" ||
typeof(win.current) == \"undefined\") {\n"
@@ -325,19 +326,20 @@
+ " }\n"
+ "}\n"
+ "if (typeof(win) != \"undefined\" &&
typeof(win.current) != \"undefined\") {\n"
- + " window.parent.setTimeout(function() {\n" + "
win.current.close();\n"
- + " }, 0);\n"
- + "}";
+ + " var close = function(w) { w.setTimeout(function()
{\n"
+ + " win.current.close();\n"
+ + " }, 0); } \n"
+ + " try { close(window.parent); } catch (ignore) {
close(window); };\n" + "}";
}
/**
* Returns the id of content component.
- *
+ *
* <pre>
* ModalWindow window = new ModalWindow(parent, "window");
* new MyPanel(window, window.getContentId());
* </pre>
- *
+ *
* @return Id of content component.
*/
public String getContentId()
@@ -348,7 +350,7 @@
/**
* 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).
- *
+ *
* @param minimalWidth
* Minimal window width.
*/
@@ -359,7 +361,7 @@
/**
* Returns the minimal width of window (in pixels).
- *
+ *
* @return Minimal width of window
*/
public int getMinimalWidth()
@@ -370,7 +372,7 @@
/**
* 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).
- *
+ *
* @param minimalHeight
* Minimal height
*/
@@ -381,7 +383,7 @@
/**
* Returns the minimal height of window (in pixels).
- *
+ *
* @return Minimal height of window
*/
public int getMinimalHeight()
@@ -403,7 +405,7 @@
* 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
<code>[EMAIL PROTECTED] #CSS_CLASS_BLUE}</code>
* and <code>[EMAIL PROTECTED] #CSS_CLASS_GRAY}</code>.
- *
+ *
* @param cssClassName
*/
public void setCssClassName(String cssClassName)
@@ -413,7 +415,7 @@
/**
* Returns the CSS class name for this window.
- *
+ *
* @return CSS class name
*/
public String getCssClassName()
@@ -427,7 +429,7 @@
* is not resizable, the unit can be specified using [EMAIL PROTECTED]
#setWidthUnit(String)}. If cookie
* name is set and window is resizable, the initial width may be
ignored in favor of width
* stored in cookie.
- *
+ *
* @param initialWidth
* Initial width of the window
*/
@@ -438,7 +440,7 @@
/**
* Returns the initial width of the window.
- *
+ *
* @return Initial height of the window
*/
public int getInitialWidth()
@@ -452,7 +454,7 @@
* not resizable, the unit can be specified using [EMAIL PROTECTED]
#setHeightUnit(String)}. If cookie
* name is set and window is resizable, the initial height may be
ignored in favor of height
* stored in cookie.
- *
+ *
* @param initialHeight
* Initial height of the window
*/
@@ -463,7 +465,7 @@
/**
* Returns the initial height of the window.
- *
+ *
* @return Initial height of the window
*/
public int getInitialHeight()
@@ -474,7 +476,7 @@
/**
* 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.
- *
+ *
* @param useInitialHeight
* Whether to use initial height instead of preserving
content height instead of
* using initial height
@@ -487,7 +489,7 @@
/**
* Returns true if the initial height should be used (in favor of
preserving real content
* height).
- *
+ *
* @return 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)
@@ -499,7 +501,7 @@
/**
* Sets whether the user will be able to resize the window.
- *
+ *
* @param resizable
* Whether the window is resizable
*/
@@ -510,7 +512,7 @@
/**
* Returns whether the window is resizable.
- *
+ *
* @return True if the window is resizable, false otherwise
*/
public boolean isResizable()
@@ -521,7 +523,7 @@
/**
* Sets the CSS unit used for initial window width. This is only
applicable when the window is
* not resizable.
- *
+ *
* @param widthUnit
* CSS unit for initial window width.
*/
@@ -532,7 +534,7 @@
/**
* Returns the CSS unit for initial window width.
- *
+ *
* @return CSS unit for initial window width.
*/
public String getWidthUnit()
@@ -543,7 +545,7 @@
/**
* Sets the CSS unit used for initial window height. This is only
applicable when the window is
* not resizable.
- *
+ *
* @param heightUnit
* CSS unit for initial window height.
*/
@@ -554,7 +556,7 @@
/**
* Retrns the CSS unit for initial window height.
- *
+ *
* @return CSS unit for initial window height.
*/
public String getHeightUnit()
@@ -565,7 +567,7 @@
/**
* Sets the name of the cookie that is used to remember window position
(and size if the window
* is resizable).
- *
+ *
* @param cookieName
* Name of the cookie
*/
@@ -581,7 +583,7 @@
/**
* Returns the name of cookie that is used to remember window position
(and size if the window
* is resizable).
- *
+ *
* @return Name of the cookie
*/
public String getCookieName()
@@ -592,7 +594,7 @@
/**
* Sets the title of window. If the window is a page, title can be
<code>null</code>. In that
* case it will display the title document inside the window.
- *
+ *
* @param title
* Title of the window
*/
@@ -604,7 +606,7 @@
/**
* Sets the title of window. If the window is a page, title can be
<code>null</code>. In that
* case it will display the title document inside the window.
- *
+ *
* @param title
* Title of the window
*/
@@ -616,7 +618,7 @@
/**
* Returns the title of the window.
- *
+ *
* @return Title of the window
*/
public IModel getTitle()
@@ -631,7 +633,7 @@
* <li><code>[EMAIL PROTECTED] #TRANSPARENT}</code> - the mask is
invisible
* <li><code>[EMAIL PROTECTED] #SEMI_TRANSPARENT}</code> - the mask is
black with small opacity (10%)
* </ul>
- *
+ *
* @author Matej Knopp
*/
public static final class MaskType extends EnumeratedType
@@ -651,7 +653,7 @@
/**
* Constructor.
- *
+ *
* @param name
*/
public MaskType(String name)
@@ -662,7 +664,7 @@
/**
* Sets the mask type of the window.
- *
+ *
* @param mask
* The mask type
*/
@@ -673,7 +675,7 @@
/**
* Returns the mask type of the window
- *
+ *
* @return The mask type
*/
public MaskType getMaskType()
@@ -683,7 +685,7 @@
/**
* Creates the page.
- *
+ *
* @return Page instance or null if page couldn't be created.
*/
private Page createPage()
@@ -751,7 +753,7 @@
/**
* Returns a content component. In case user haven't specified any
content component, it returns
* an empty WebMarkupContainer.
- *
+ *
* @return Content component
*/
private Component getContent()
@@ -761,7 +763,7 @@
/**
* Returns true if user has added own component to the window.
- *
+ *
* @return True if user has added own component to the window, false
otherwise.
*/
private boolean isCustomComponent()
@@ -783,7 +785,7 @@
/**
* Sets the content of the modal window.
- *
+ *
* @param component
*/
public void setContent(Component component)
@@ -872,7 +874,7 @@
/**
* Returns the markup id of the component.
- *
+ *
* @return component id
*/
private String getContentMarkupId()
@@ -882,10 +884,10 @@
/**
* Replaces all occurrences of " in string with \".
- *
+ *
* @param string
* String to be escaped.
- *
+ *
* @return escaped string
*/
private String escapeQuotes(String string)
@@ -899,7 +901,7 @@
/**
* Returns the javascript used to open the window.
- *
+ *
* @return javascript that opens the window
*/
private String getWindowOpenJavascript()
@@ -1008,7 +1010,7 @@
/**
* Method that allows tweaking the settings
- *
+ *
* @param settings
* @return settings javascript
*/
@@ -1041,12 +1043,13 @@
private PageCreator pageCreator = null;
private CloseButtonCallback closeButtonCallback = null;
private WindowClosedCallback windowClosedCallback = null;
-
+
protected void onDetach()
{
super.onDetach();
- if (this.title != null) {
- this.title.detach();
+ if (title != null)
+ {
+ title.detach();
}
}
}