Repository: wicket
Updated Branches:
  refs/heads/master 04125f63d -> a3b602400


WICKET-5929 IPartialPageRequestHandler for updating of components


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

Branch: refs/heads/master
Commit: a3b602400eb5bf2467be1c42c187633fa83b59a4
Parents: 04125f6
Author: Sven Meier <[email protected]>
Authored: Tue Jun 23 14:05:43 2015 +0200
Committer: Sven Meier <[email protected]>
Committed: Tue Jun 23 14:06:01 2015 +0200

----------------------------------------------------------------------
 .../apache/wicket/ajax/AjaxRequestTarget.java   | 109 +---------------
 .../handler/IPartialPageRequestHandler.java     | 129 +++++++++++++++++++
 .../ws/api/IWebSocketRequestHandler.java        |   5 +-
 .../ws/api/WebSocketRequestHandler.java         |  13 +-
 4 files changed, 136 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/a3b60240/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java 
b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
index 4b46f8c..9caad44 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
@@ -16,22 +16,19 @@
  */
 package org.apache.wicket.ajax;
 
-import java.util.Collection;
 import java.util.Map;
 
 import org.apache.wicket.Component;
-import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.Page;
 import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
-import org.apache.wicket.core.request.handler.IPageRequestHandler;
-import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
 import org.apache.wicket.request.ILoggableRequestHandler;
 
 /**
  *
  * @since 6.0
  */
-public interface AjaxRequestTarget extends IPageRequestHandler, 
ILoggableRequestHandler
+public interface AjaxRequestTarget extends IPartialPageRequestHandler, 
ILoggableRequestHandler
 {
        /**
         * An {@link AjaxRequestTarget} listener that can be used to respond to 
various target-related
@@ -135,43 +132,6 @@ public interface AjaxRequestTarget extends 
IPageRequestHandler, ILoggableRequest
                void onTargetRespond(AjaxRequestTarget target);
        }
 
-
-       /**
-        * Adds a component to the list of components to be rendered
-        *
-        * @param markupId
-        *            id of client-side dom element that will be updated
-        * @param component
-        *            component to be rendered
-        * @throws IllegalArgumentException
-        *             if the component is a {@link org.apache.wicket.Page} or 
an {@link org.apache.wicket.markup.repeater.AbstractRepeater}
-        * @throws IllegalStateException
-        *             if the components are currently being rendered, or have 
already been rendered
-        */
-       void add(final Component component, final String markupId);
-
-       /**
-        * Adds components to the list of components to be rendered.
-        *
-        * @param components
-        *            components to be rendered
-        */
-       void add(Component... components);
-
-
-       /**
-        * Visits all children of the specified parent container and adds them 
to the target if they are
-        * of same type as <code>childCriteria</code>
-        *
-        * @param parent
-        *            Must not be null.
-        * @param childCriteria
-        *            Must not be null. If you want to traverse all components 
use ` Component.class as
-        *            the value for this argument.
-        */
-       void addChildren(MarkupContainer parent, Class<?> childCriteria);
-
-
        /**
         * Adds a listener to this target
         *
@@ -183,36 +143,6 @@ public interface AjaxRequestTarget extends 
IPageRequestHandler, ILoggableRequest
        void addListener(AjaxRequestTarget.IListener listener);
 
        /**
-        * Adds javascript that will be evaluated on the client side after 
components are replaced
-        *
-        * <p>If the javascript needs to do something asynchronously (i.e. 
needs to use window.setTimeout(), for example
-        * to do animations) then the following special syntax may be used: 
<code>someFunctionName|myJsLogic(someFunctionName);</code>.
-        * Wicket will transform it to: 
<code>function(someFunctionName){myJsLogic(someFunctionName);}</code> and your 
code
-        * is responsible to execute <em>someFunctionName()</em> when the 
asynchronous task is finished. Once <em>someFunctionName</em>
-        * is executed the next appended script will be executed. 
<strong>Important</strong>: it is highly recommended to
-        * execute your code in try/finally to make sure 
<em>someFunctionName</em> is executed even an error happens in
-        * your code, otherwise all following scripts wont be executed.</p>
-        *
-        * @param javascript
-        */
-       void appendJavaScript(CharSequence javascript);
-
-       /**
-        * Adds javascript that will be evaluated on the client side before 
components are replaced.
-        *
-        * <p>If the javascript needs to do something asynchronously (i.e. 
needs to use window.setTimeout(), for example
-        * to do animations) then the following special syntax may be used: 
<code>someFunctionName|myJsLogic(someFunctionName);</code>.
-        * Wicket will transform it to: 
<code>function(someFunctionName){myJsLogic(someFunctionName);}</code> and your 
code
-        * is responsible to execute <em>someFunctionName()</em> when the 
asynchronous task is finished. Once <em>someFunctionName</em>
-        * is executed the next prepended script will be executed. 
<strong>Important</strong>: it is highly recommended to
-        * execute your code in try/finally to make sure 
<em>someFunctionName</em> is executed even an error happens in
-        * your code, otherwise all following scripts and component 
replacements wont be made.</p>
-        *
-        * @param javascript
-        */
-       void prependJavaScript(CharSequence javascript);
-
-       /**
         * Register the given respond listener. The listener's
         * {@link 
org.apache.wicket.ajax.AjaxRequestTarget.ITargetRespondListener#onTargetRespond}
 method will be invoked when
         * the {@link AjaxRequestTarget} starts to respond.
@@ -222,41 +152,6 @@ public interface AjaxRequestTarget extends 
IPageRequestHandler, ILoggableRequest
        void registerRespondListener(ITargetRespondListener listener);
 
        /**
-        * Returns an unmodifiable collection of all components added to this 
target
-        *
-        * @return unmodifiable collection of all components added to this 
target
-        */
-       Collection<? extends Component> getComponents();
-
-       /**
-        * Sets the focus in the browser to the given component. The markup id 
must be set. If the
-        * component is null the focus will not be set to any component.
-        *
-        * @param component
-        *            The component to get the focus or null.
-        */
-       void focusComponent(Component component);
-
-       /**
-        * Returns the header response associated with current 
AjaxRequestTarget.
-        *
-        * Beware that only renderOnDomReadyJavaScript and 
renderOnLoadJavaScript can be called outside
-        * the renderHeader(IHeaderResponse response) method. Calls to other 
render** methods will
-        * result in the call failing with a debug-level log statement to help 
you see why it failed.
-        *
-        * @return header response
-        */
-       IHeaderResponse getHeaderResponse();
-
-       /**
-        * Returns the HTML id of the last focused element.
-        *
-        * @return markup id of last focused element, <code>null</code> if none
-        */
-       String getLastFocusedElementId();
-
-
-       /**
         * Returns the page. Be aware that the page can be instantiated if this 
wasn't the case already.
         *
         * @return page instance

http://git-wip-us.apache.org/repos/asf/wicket/blob/a3b60240/wicket-core/src/main/java/org/apache/wicket/core/request/handler/IPartialPageRequestHandler.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/IPartialPageRequestHandler.java
 
b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/IPartialPageRequestHandler.java
new file mode 100644
index 0000000..806028f
--- /dev/null
+++ 
b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/IPartialPageRequestHandler.java
@@ -0,0 +1,129 @@
+/*
+ * 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.core.request.handler;
+
+import java.util.Collection;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.markup.head.IHeaderResponse;
+
+/**
+ * Request handler that allows partial updates of the current page instance.
+ */
+public interface IPartialPageRequestHandler extends IPageRequestHandler
+{
+
+       /**
+        * Adds a component to the list of components to be rendered
+        *
+        * @param markupId
+        *            id of client-side dom element that will be updated
+        * @param component
+        *            component to be rendered
+        * @throws IllegalArgumentException
+        *             if the component is a {@link org.apache.wicket.Page} or 
an {@link org.apache.wicket.markup.repeater.AbstractRepeater}
+        * @throws IllegalStateException
+        *             if the components are currently being rendered, or have 
already been rendered
+        */
+       void add(final Component component, final String markupId);
+
+       /**
+        * Adds components to the list of components to be rendered.
+        *
+        * @param components
+        *            components to be rendered
+        */
+       void add(Component... components);
+
+
+       /**
+        * Visits all children of the specified parent container and adds them 
to the target if they are
+        * of same type as <code>childCriteria</code>
+        *
+        * @param parent
+        *            Must not be null.
+        * @param childCriteria
+        *            Must not be null. If you want to traverse all components 
use ` Component.class as
+        *            the value for this argument.
+        */
+       void addChildren(MarkupContainer parent, Class<?> childCriteria);
+
+       /**
+        * Adds javascript that will be evaluated on the client side after 
components are replaced
+        *
+        * <p>If the javascript needs to do something asynchronously (i.e. 
needs to use window.setTimeout(), for example
+        * to do animations) then the following special syntax may be used: 
<code>someFunctionName|myJsLogic(someFunctionName);</code>.
+        * Wicket will transform it to: 
<code>function(someFunctionName){myJsLogic(someFunctionName);}</code> and your 
code
+        * is responsible to execute <em>someFunctionName()</em> when the 
asynchronous task is finished. Once <em>someFunctionName</em>
+        * is executed the next appended script will be executed. 
<strong>Important</strong>: it is highly recommended to
+        * execute your code in try/finally to make sure 
<em>someFunctionName</em> is executed even an error happens in
+        * your code, otherwise all following scripts wont be executed.</p>
+        *
+        * @param javascript
+        */
+       void appendJavaScript(CharSequence javascript);
+
+       /**
+        * Adds javascript that will be evaluated on the client side before 
components are replaced.
+        *
+        * <p>If the javascript needs to do something asynchronously (i.e. 
needs to use window.setTimeout(), for example
+        * to do animations) then the following special syntax may be used: 
<code>someFunctionName|myJsLogic(someFunctionName);</code>.
+        * Wicket will transform it to: 
<code>function(someFunctionName){myJsLogic(someFunctionName);}</code> and your 
code
+        * is responsible to execute <em>someFunctionName()</em> when the 
asynchronous task is finished. Once <em>someFunctionName</em>
+        * is executed the next prepended script will be executed. 
<strong>Important</strong>: it is highly recommended to
+        * execute your code in try/finally to make sure 
<em>someFunctionName</em> is executed even an error happens in
+        * your code, otherwise all following scripts and component 
replacements wont be made.</p>
+        *
+        * @param javascript
+        */
+       void prependJavaScript(CharSequence javascript);
+
+       /**
+        * Sets the focus in the browser to the given component. The markup id 
must be set. If the
+        * component is null the focus will not be set to any component.
+        *
+        * @param component
+        *            The component to get the focus or null.
+        */
+       void focusComponent(Component component);
+
+       /**
+        * Returns the HTML id of the last focused element.
+        *
+        * @return markup id of last focused element, <code>null</code> if none
+        */
+       String getLastFocusedElementId();
+
+       /**
+        * Returns an unmodifiable collection of all components added to this 
target
+        *
+        * @return unmodifiable collection of all components added to this 
target
+        */
+       Collection<? extends Component> getComponents();
+
+       /**
+        * Returns the header response associated with current handler.
+        *
+        * Beware that only renderOnDomReadyJavaScript and 
renderOnLoadJavaScript can be called outside
+        * the renderHeader(IHeaderResponse response) method. Calls to other 
render** methods will
+        * result in the call failing with a debug-level log statement to help 
you see why it failed.
+        *
+        * @return header response
+        */
+       IHeaderResponse getHeaderResponse();
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/a3b60240/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/IWebSocketRequestHandler.java
----------------------------------------------------------------------
diff --git 
a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/IWebSocketRequestHandler.java
 
b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/IWebSocketRequestHandler.java
index ba8ec9e..8d49155 100644
--- 
a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/IWebSocketRequestHandler.java
+++ 
b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/IWebSocketRequestHandler.java
@@ -16,12 +16,15 @@
  */
 package org.apache.wicket.protocol.ws.api;
 
+import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
+import org.apache.wicket.request.ILoggableRequestHandler;
+
 /**
  * An interface for outbound communication with web socket clients
  *
  * @since 6.0
  */
-public interface IWebSocketRequestHandler
+public interface IWebSocketRequestHandler extends IPartialPageRequestHandler, 
ILoggableRequestHandler
 {
        /**
         * Pushes a text message to the client.

http://git-wip-us.apache.org/repos/asf/wicket/blob/a3b60240/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestHandler.java
----------------------------------------------------------------------
diff --git 
a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestHandler.java
 
b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestHandler.java
index 1363866..2a14374 100644
--- 
a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestHandler.java
+++ 
b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestHandler.java
@@ -24,7 +24,6 @@ import org.apache.wicket.Component;
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.Page;
 import org.apache.wicket.ajax.AbstractAjaxResponse;
-import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.XmlAjaxResponse;
 import org.apache.wicket.core.request.handler.logger.PageLogData;
 import org.apache.wicket.markup.head.IHeaderResponse;
@@ -47,7 +46,7 @@ import org.slf4j.LoggerFactory;
  *
  * @since 6.0
  */
-public class WebSocketRequestHandler implements AjaxRequestTarget, 
IWebSocketRequestHandler
+public class WebSocketRequestHandler implements IWebSocketRequestHandler
 {
        private static final Logger LOG = 
LoggerFactory.getLogger(WebSocketRequestHandler.class);
 
@@ -165,11 +164,6 @@ public class WebSocketRequestHandler implements 
AjaxRequestTarget, IWebSocketReq
        }
 
        @Override
-       public void addListener(IListener listener)
-       {
-       }
-
-       @Override
        public void appendJavaScript(CharSequence javascript)
        {
                hasData.set(true);
@@ -184,11 +178,6 @@ public class WebSocketRequestHandler implements 
AjaxRequestTarget, IWebSocketReq
        }
 
        @Override
-       public void registerRespondListener(ITargetRespondListener listener)
-       {
-       }
-
-       @Override
        public Collection<? extends Component> getComponents()
        {
                return ajaxResponse.getComponents();

Reply via email to