Author: gseitz
Date: Sat May 17 11:17:46 2008
New Revision: 657412

URL: http://svn.apache.org/viewvc?rev=657412&view=rev
Log:
WICKET-1541: replace all non word characters in windowtitle with "_"

Modified:
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/PopupSettings.java

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/PopupSettings.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/PopupSettings.java?rev=657412&r1=657411&r2=657412&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/PopupSettings.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/PopupSettings.java
 Sat May 17 11:17:46 2008
@@ -102,11 +102,11 @@
 
        /**
         * Construct. If you are not using these popup settings with an 
external link - in which case we
-        * don't need to know about a page map - you should use one of the 
constructors with a
-        * [EMAIL PROTECTED] PageMap} argument. Typically, you should put any 
popup in a separate page map as
-        * Wicket holds references to a limited number of pages/ versions only. 
If you don't put your
-        * popup in a separate page map, the user might get page expired 
exceptions when getting back to
-        * the main window again.
+        * don't need to know about a page map - you should use one of the 
constructors with a [EMAIL PROTECTED]
+        * PageMap} argument. Typically, you should put any popup in a separate 
page map as Wicket holds
+        * references to a limited number of pages/ versions only. If you don't 
put your popup in a
+        * separate page map, the user might get page expired exceptions when 
getting back to the main
+        * window again.
         */
        public PopupSettings()
        {
@@ -116,44 +116,46 @@
         * Construct.
         * 
         * @param displayFlags
-        *            Display flags
+        *              Display flags
         */
        public PopupSettings(final int displayFlags)
        {
-               this.displayFlags = displayFlags;
+               this(null, displayFlags);
        }
 
        /**
         * Construct.
         * 
         * @param pagemap
-        *            The pagemap where this popup must be in. Typically, you 
should put any popup in a
-        *            separate page map as Wicket holds references to a limited 
number of pages/
-        *            versions only. If you don't put your popup in a separate 
page map, the user might
-        *            get page expired exceptions when getting back to the main 
window again.
+        *              The pagemap where this popup must be in. Typically, you 
should put any popup in a
+        *              separate page map as Wicket holds references to a 
limited number of pages/ versions
+        *              only. If you don't put your popup in a separate page 
map, the user might get page
+        *              expired exceptions when getting back to the main window 
again.
         */
        public PopupSettings(IPageMap pagemap)
        {
-               pageMapName = pagemap.getName();
-               windowName = pageMapName;
+               this(pagemap, 0);
        }
 
        /**
         * Construct.
         * 
         * @param pagemap
-        *            The pagemap where this popup must be in. Typically, you 
should put any popup in a
-        *            separate page map as Wicket holds references to a limited 
number of pages/
-        *            versions only. If you don't put your popup in a separate 
page map, the user might
-        *            get page expired exceptions when getting back to the main 
window again.
+        *              The pagemap where this popup must be in. Typically, you 
should put any popup in a
+        *              separate page map as Wicket holds references to a 
limited number of pages/ versions
+        *              only. If you don't put your popup in a separate page 
map, the user might get page
+        *              expired exceptions when getting back to the main window 
again.
         * @param displayFlags
-        *            Display flags
+        *              Display flags
         */
        public PopupSettings(IPageMap pagemap, final int displayFlags)
        {
                this.displayFlags = displayFlags;
-               pageMapName = pagemap.getName();
-               windowName = pageMapName;
+               if (pagemap != null)
+               {
+                       pageMapName = pagemap.getName();
+                       windowName = pageMapName;
+               }
        }
 
        /**
@@ -172,11 +174,11 @@
                else
                {
                        // Fix for IE bug.
-                       windowTitle = windowTitle.replace(':', '_');
+                       windowTitle = windowTitle.replaceAll("\\W", "_");
                }
 
                StringBuffer script = new StringBuffer("var w = window.open(" + 
target + ", '").append(
-                               windowTitle).append("', '");
+                       windowTitle).append("', '");
 
                script.append("scrollbars=").append(flagToString(SCROLLBARS));
                script.append(",location=").append(flagToString(LOCATION_BAR));
@@ -214,7 +216,7 @@
         * Sets the popup window height.
         * 
         * @param popupHeight
-        *            the popup window height.
+        *              the popup window height.
         * @return This
         */
        public PopupSettings setHeight(int popupHeight)
@@ -227,7 +229,7 @@
         * Sets the left position of the popup window.
         * 
         * @param popupPositionLeft
-        *            the left position of the popup window.
+        *              the left position of the popup window.
         * @return This
         */
        public PopupSettings setLeft(int popupPositionLeft)
@@ -242,7 +244,7 @@
         * setting the target explicitly.
         * 
         * @param target
-        *            the target of the link
+        *              the target of the link
         */
        public void setTarget(String target)
        {
@@ -253,7 +255,7 @@
         * Sets the top position of the popup window.
         * 
         * @param popupPositionTop
-        *            the top position of the popup window.
+        *              the top position of the popup window.
         * @return This
         */
        public PopupSettings setTop(int popupPositionTop)
@@ -266,7 +268,7 @@
         * Sets the popup window width.
         * 
         * @param popupWidth
-        *            the popup window width.
+        *              the popup window width.
         * @return This
         */
        public PopupSettings setWidth(int popupWidth)
@@ -282,7 +284,7 @@
         * will be reused rather than opening a second window
         * 
         * @param popupWindowName
-        *            window name.
+        *              window name.
         * @return This
         */
        public PopupSettings setWindowName(String popupWindowName)
@@ -293,8 +295,8 @@
                        if (pageMapName != null && 
(!pageMapName.equals(popupWindowName)))
                        {
                                log.warn("the page map and window name should 
be the same. The page map was " +
-                                               pageMapName + ", and the 
requested window name is " + popupWindowName +
-                                               "; changing the page map to " + 
popupWindowName);
+                                       pageMapName + ", and the requested 
window name is " + popupWindowName +
+                                       "; changing the page map to " + 
popupWindowName);
                        }
                        pageMapName = popupWindowName;
                }
@@ -303,7 +305,7 @@
 
        /**
         * @param flag
-        *            The flag to test
+        *              The flag to test
         * @return Yes or no depending on whether the flag is set
         */
        private String flagToString(final int flag)
@@ -326,8 +328,8 @@
                else
                {
                        throw new UnsupportedOperationException(
-                                       "this method can only work when a page 
map is set. Either call"
-                                                       + " 
getPageMap(Component) or set the page map");
+                               "this method can only work when a page map is 
set. Either call"
+                                       + " getPageMap(Component) or set the 
page map");
                }
        }
 
@@ -335,7 +337,7 @@
         * Gets the pagemap where the popup page must be created in.
         * 
         * @param callee
-        *            Calling component
+        *              Calling component
         * @return The pagemap where the popup page must be created in
         */
        public IPageMap getPageMap(Component callee)
@@ -349,15 +351,15 @@
                        if (callee == null)
                        {
                                throw new IllegalArgumentException(
-                                               "when the page map is not set, 
argument callee may not be null");
+                                       "when the page map is not set, argument 
callee may not be null");
                        }
                        Page page = callee.getPage();
                        if (page == null)
                        {
                                throw new IllegalStateException(callee +
-                                               " is not yet set on a page; if 
you want to use this method " +
-                                               "without a page map being set, 
argument callee must be not null " +
-                                               "and added to a page");
+                                       " is not yet set on a page; if you want 
to use this method " +
+                                       "without a page map being set, argument 
callee must be not null " +
+                                       "and added to a page");
                        }
                        return page.getPageMap();
                }


Reply via email to