Updated Branches:
  refs/heads/master e211db8d6 -> 5f38faf51

WICKET-4308 Rename to AjaxNewWindowNotifyingBehavior to be more like the other 
ajax behaviors


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/5f38faf5
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/5f38faf5
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/5f38faf5

Branch: refs/heads/master
Commit: 5f38faf51476361a85cb8dff6dfeaab174d26a0c
Parents: e211db8
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Sun May 13 15:17:21 2012 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Sun May 13 15:17:21 2012 +0200

----------------------------------------------------------------------
 .../ajax/AjaxNewWindowNotifyingBehavior.java       |  128 +++++++++++++++
 .../org/apache/wicket/ajax/NewWindowNotifier.java  |  128 ---------------
 2 files changed, 128 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/5f38faf5/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxNewWindowNotifyingBehavior.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxNewWindowNotifyingBehavior.java
 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxNewWindowNotifyingBehavior.java
new file mode 100644
index 0000000..ae8ea0a
--- /dev/null
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxNewWindowNotifyingBehavior.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.ajax;
+
+import java.util.UUID;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
+import org.apache.wicket.markup.head.OnLoadHeaderItem;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.util.string.StringValue;
+
+/**
+ * An Ajax behavior that notifies when a new browser window/tab is opened with
+ * url to a page instance which is already opened in another window/tab in the 
same user session.
+ *
+ * Note: this behavior may be assigned only to an instance of a WebPage class.
+ *
+ * @since 6.0
+ */
+public abstract class AjaxNewWindowNotifyingBehavior extends 
AbstractDefaultAjaxBehavior
+{
+       /**
+        * A unique name used for the page window's name
+        */
+       private final String windowName;
+
+       /**
+        * The name of the HTTP request parameter that brings the current page 
window's name.
+        */
+       private static final String PARAM_WINDOW_NAME = "windowName";
+
+       /**
+        * A flag whether this behavior has been rendered at least once.
+        */
+       private boolean hasBeenRendered;
+
+       /**
+        * Constructor.
+        */
+       public AjaxNewWindowNotifyingBehavior()
+       {
+               this(UUID.randomUUID().toString());
+       }
+
+       /**
+        * Constructor.
+        *
+        * @param windowName
+        *      the custom name to use for the page's window
+        */
+       public AjaxNewWindowNotifyingBehavior(final String windowName)
+       {
+               this.windowName = windowName;
+       }
+
+       @Override
+       protected final void onBind()
+       {
+               super.onBind();
+
+               Component component = getComponent();
+               if (component instanceof WebPage == false)
+               {
+                       throw new 
WicketRuntimeException(AjaxNewWindowNotifyingBehavior.class.getName() + " can 
be assigned only to WebPage instances.");
+               }
+       }
+
+       @Override
+       protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
+       {
+               super.updateAjaxAttributes(attributes);
+               
+               String uuidParam = "return {'"+ PARAM_WINDOW_NAME +"': 
window.name}";
+               attributes.getDynamicExtraParameters().add(uuidParam);
+       }
+
+       @Override
+       public void renderHead(Component component, IHeaderResponse response)
+       {
+               super.renderHead(component, response);
+
+               if (hasBeenRendered == false)
+               {
+                       hasBeenRendered = true;
+                       
response.render(OnDomReadyHeaderItem.forScript(String.format("window.name='%s'",
 windowName)));
+               }
+               
response.render(OnLoadHeaderItem.forScript("setTimeout(function() {" + 
getCallbackScript().toString() + "}, 30);"));
+       }
+
+       @Override
+       protected void respond(AjaxRequestTarget target)
+       {
+               StringValue uuidParam = 
getComponent().getRequest().getRequestParameters().getParameterValue(PARAM_WINDOW_NAME);
+
+               if (windowName.equals(uuidParam.toString()) == false)
+               {
+                       onNewWindow(target);
+               }
+       }
+
+       /**
+        * A callback method when a new window/tab is opened for a page instance
+        * which is already opened in another window/tab.
+        *
+        * @param target
+        *      the current ajax request handler
+        */
+       protected abstract void onNewWindow(AjaxRequestTarget target);
+
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/5f38faf5/wicket-core/src/main/java/org/apache/wicket/ajax/NewWindowNotifier.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/NewWindowNotifier.java 
b/wicket-core/src/main/java/org/apache/wicket/ajax/NewWindowNotifier.java
deleted file mode 100644
index f917ba6..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/NewWindowNotifier.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.ajax;
-
-import java.util.UUID;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
-import org.apache.wicket.markup.head.OnLoadHeaderItem;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.util.string.StringValue;
-
-/**
- * An Ajax behavior that notifies when a new browser window/tab is opened with
- * url to a page instance which is already opened in another window/tab.
- *
- * Note: this behavior may be assigned only to an instance of a WebPage class.
- *
- * @since 6.0
- */
-public abstract class NewWindowNotifier extends AbstractDefaultAjaxBehavior
-{
-       /**
-        * A unique name used for the page window's name
-        */
-       private final String windowName;
-
-       /**
-        * The name of the HTTP request parameter that brings the current page 
window's name.
-        */
-       private static final String PARAM_WINDOW_NAME = "windowName";
-
-       /**
-        * A flag whether this behavior has been rendered at least once.
-        */
-       private boolean hasBeenRendered;
-
-       /**
-        * Constructor.
-        */
-       public NewWindowNotifier()
-       {
-               this(UUID.randomUUID().toString());
-       }
-
-       /**
-        * Constructor.
-        *
-        * @param windowName
-        *      the custom name to use for the page's window
-        */
-       public NewWindowNotifier(final String windowName)
-       {
-               this.windowName = windowName;
-       }
-
-       @Override
-       protected final void onBind()
-       {
-               super.onBind();
-
-               Component component = getComponent();
-               if (component instanceof WebPage == false)
-               {
-                       throw new 
WicketRuntimeException(NewWindowNotifier.class.getName() + " can be assigned 
only to WebPage instances.");
-               }
-       }
-
-       @Override
-       protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
-       {
-               super.updateAjaxAttributes(attributes);
-               
-               String uuidParam = "return {'"+ PARAM_WINDOW_NAME +"': 
window.name}";
-               attributes.getDynamicExtraParameters().add(uuidParam);
-       }
-
-       @Override
-       public void renderHead(Component component, IHeaderResponse response)
-       {
-               super.renderHead(component, response);
-
-               if (hasBeenRendered == false)
-               {
-                       hasBeenRendered = true;
-                       
response.render(OnDomReadyHeaderItem.forScript(String.format("window.name='%s'",
 windowName)));
-               }
-               
response.render(OnLoadHeaderItem.forScript("setTimeout(function() {" + 
getCallbackScript().toString() + "}, 30);"));
-       }
-
-       @Override
-       protected void respond(AjaxRequestTarget target)
-       {
-               StringValue uuidParam = 
getComponent().getRequest().getRequestParameters().getParameterValue(PARAM_WINDOW_NAME);
-
-               if (windowName.equals(uuidParam.toString()) == false)
-               {
-                       onNewWindow(target);
-               }
-       }
-
-       /**
-        * A callback method when a new window/tab is opened for a page instance
-        * which is already opened in another window/tab.
-        *
-        * @param target
-        *      the current ajax request handler
-        */
-       protected abstract void onNewWindow(AjaxRequestTarget target);
-
-}

Reply via email to