tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r709564 - in /tapestry/tapestry5/trunk: src/site/apt/ src/site/apt/guide/ tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ tapestry-core/src/main/java/org/apache/tapestry5/services/ tapestry-core/src/main/java/org/apache/...
Date Fri, 31 Oct 2008 20:54:26 GMT
Author: hlship
Date: Fri Oct 31 13:54:25 2008
New Revision: 709564

URL: http://svn.apache.org/viewvc?rev=709564&view=rev
Log:
TAP5-187: Ajax event handler methods that return a page instance, page class or page name
should cause the client to redirect to that page

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxLinkComponentEventResultProcessor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageClassComponentEventResultProcessor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageNameComponentEventResultProcessor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageNameComponentEventResultProcessor.java
      - copied, changed from r704144, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StringResultProcessor.java
Removed:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StringResultProcessor.java
Modified:
    tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt
    tapestry/tapestry5/trunk/src/site/apt/index.apt
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/nested/ZoneDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/ZoneDemo.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessorTest.java

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt Fri Oct 31 13:54:25 2008
@@ -249,6 +249,12 @@
   This return value should be an injected component or block.  The value will be rendered,
and that
   markup will be used on the client side to update the Zone's \<div\>.
 
+  An event handler may return a
+  {{{../apidocs/org/apache/tapestry5/Link.html}Link}} and the client will be redirected to
that link.
+
+  Returning a page name (as a String), or a page class, or a page instance will also send
a redirect
+  to the indicated page.
+
 ** Graceful Degradation
 
   Users who do not have JavaScript enabled may click ActionLinks that are configured to update
a Zone.

Modified: tapestry/tapestry5/trunk/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/index.apt?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/index.apt Fri Oct 31 13:54:25 2008
@@ -68,6 +68,9 @@
 
 New And Of Note
 
+  * Event handler methods for Ajax requests may now return a page name, page class or page
instance to force
+    the browser to redirect to the page.
+
   * The Inject and InjectService annotations may now be used on fields of service implementations
or other
     objects constructed by the IoC container. In the past, injections only occured through
method or
     constructor parameters.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessor.java?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessor.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessor.java
Fri Oct 31 13:54:25 2008
@@ -18,6 +18,7 @@
 import org.apache.tapestry5.internal.structure.Page;
 import org.apache.tapestry5.runtime.Component;
 import org.apache.tapestry5.runtime.RenderCommand;
+import org.apache.tapestry5.services.Ajax;
 import org.apache.tapestry5.services.ComponentEventResultProcessor;
 
 import java.io.IOException;
@@ -29,29 +30,39 @@
 {
     private final RequestPageCache cache;
 
-    private final PageRenderQueue pageRenderQueue;
+    private final ComponentEventResultProcessor masterProcessor;
 
-    public AjaxComponentInstanceEventResultProcessor(RequestPageCache cache, PageRenderQueue
pageRenderQueue)
+    public AjaxComponentInstanceEventResultProcessor(RequestPageCache cache,
+                                                     @Ajax ComponentEventResultProcessor
masterProcessor)
     {
         this.cache = cache;
-        this.pageRenderQueue = pageRenderQueue;
+        this.masterProcessor = masterProcessor;
     }
 
     public void processResultValue(Component value) throws IOException
     {
         ComponentResources resources = value.getComponentResources();
 
+        boolean isPage = value == resources.getPage();
+
         String pageName = resources.getPageName();
 
+        if (isPage)
+        {
+            // This will ultimately send a JSON response to redirect to the page
+
+            masterProcessor.processResultValue(pageName);
+            return;
+        }
+
+        // Otherwise, a component within a page.
+
         Page page = cache.get(pageName);
 
         String nestedId = resources.getNestedId();
 
-        // The user may return a complete page instance, which isn't really a partial render,
I guess.
-        // Depends on the structure of the page returned.
-
-        RenderCommand command = nestedId == null ? page.getRootElement() : page.getComponentElementByNestedId(nestedId);
+        RenderCommand command = page.getComponentElementByNestedId(nestedId);
 
-        pageRenderQueue.initializeForPartialPageRender(command);
+        masterProcessor.processResultValue(command);
     }
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxLinkComponentEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxLinkComponentEventResultProcessor.java?rev=709564&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxLinkComponentEventResultProcessor.java
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxLinkComponentEventResultProcessor.java
Fri Oct 31 13:54:25 2008
@@ -0,0 +1,44 @@
+//  Copyright 2008 The Apache Software Foundation
+//
+// Licensed 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.tapestry5.internal.services;
+
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.json.JSONObject;
+import org.apache.tapestry5.services.Ajax;
+import org.apache.tapestry5.services.ComponentEventResultProcessor;
+
+import java.io.IOException;
+
+/**
+ * Handles {@link org.apache.tapestry5.Link} result types by building a JSON response with
key "redirectURL".
+ */
+public class AjaxLinkComponentEventResultProcessor implements ComponentEventResultProcessor<Link>
+{
+    private final ComponentEventResultProcessor masterProcessor;
+
+    public AjaxLinkComponentEventResultProcessor(@Ajax ComponentEventResultProcessor masterProcessor)
+    {
+        this.masterProcessor = masterProcessor;
+    }
+
+    public void processResultValue(Link value) throws IOException
+    {
+        JSONObject response = new JSONObject();
+
+        response.put("redirectURL", value.toRedirectURI());
+
+        masterProcessor.processResultValue(response);
+    }
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageClassComponentEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageClassComponentEventResultProcessor.java?rev=709564&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageClassComponentEventResultProcessor.java
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageClassComponentEventResultProcessor.java
Fri Oct 31 13:54:25 2008
@@ -0,0 +1,48 @@
+//  Copyright 2008 The Apache Software Foundation
+//
+// Licensed 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.tapestry5.internal.services;
+
+import org.apache.tapestry5.services.Ajax;
+import org.apache.tapestry5.services.ComponentEventResultProcessor;
+import org.apache.tapestry5.services.ComponentSource;
+
+import java.io.IOException;
+
+/**
+ * Processes a Class result by converting the Class to a logical page name, then processing
that.
+ *
+ * @see org.apache.tapestry5.services.ComponentSource
+ * @see org.apache.tapestry5.internal.services.AjaxPageNameComponentEventResultProcessor
+ */
+public class AjaxPageClassComponentEventResultProcessor implements ComponentEventResultProcessor<Class>
+{
+    private final ComponentSource componentSource;
+
+    private final ComponentEventResultProcessor masterProcessor;
+
+    public AjaxPageClassComponentEventResultProcessor(ComponentSource componentSource,
+                                                      @Ajax ComponentEventResultProcessor
masterProcessor)
+    {
+        this.componentSource = componentSource;
+        this.masterProcessor = masterProcessor;
+    }
+
+    public void processResultValue(Class value) throws IOException
+    {
+        String pageName = componentSource.getPage(value).getComponentResources().getPageName();
+
+        masterProcessor.processResultValue(pageName);
+    }
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageNameComponentEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageNameComponentEventResultProcessor.java?rev=709564&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageNameComponentEventResultProcessor.java
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxPageNameComponentEventResultProcessor.java
Fri Oct 31 13:54:25 2008
@@ -0,0 +1,55 @@
+//  Copyright 2008 The Apache Software Foundation
+//
+// Licensed 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.tapestry5.internal.services;
+
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.services.Ajax;
+import org.apache.tapestry5.services.ComponentEventResultProcessor;
+
+import java.io.IOException;
+
+/**
+ * A {@link org.apache.tapestry5.services.ComponentEventResultProcessor}, used for Ajax requests,
for a String value
+ * that is interpreted as a logical page name.
+ *
+ * @see org.apache.tapestry5.internal.services.PageNameComponentEventResultProcessor
+ */
+public class AjaxPageNameComponentEventResultProcessor implements ComponentEventResultProcessor<String>
+{
+    private final ComponentEventResultProcessor masterProcessor;
+
+    private final LinkFactory linkFactory;
+
+    public AjaxPageNameComponentEventResultProcessor(@Ajax ComponentEventResultProcessor
masterProcessor,
+                                                     LinkFactory linkFactory)
+    {
+        this.masterProcessor = masterProcessor;
+        this.linkFactory = linkFactory;
+    }
+
+    /**
+     * Obtains a page render {@link org.apache.tapestry5.Link} for the named, then builds
a JSON reponse for the
+     * client.
+     *
+     * @param value page name
+     * @throws IOException
+     */
+    public void processResultValue(String value) throws IOException
+    {
+        Link link = linkFactory.createPageRenderLink(value, false);
+
+        masterProcessor.processResultValue(link);
+    }
+}

Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageNameComponentEventResultProcessor.java
(from r704144, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StringResultProcessor.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageNameComponentEventResultProcessor.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageNameComponentEventResultProcessor.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StringResultProcessor.java&r1=704144&r2=709564&rev=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StringResultProcessor.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageNameComponentEventResultProcessor.java
Fri Oct 31 13:54:25 2008
@@ -23,13 +23,14 @@
  * Used when a component event handler returns a string value. The value is interpreted as
the logical name of a page. A
  * link to the page will be sent as a redirect.
  */
-public class StringResultProcessor implements ComponentEventResultProcessor<String>
+public class PageNameComponentEventResultProcessor implements ComponentEventResultProcessor<String>
 {
     private final RequestPageCache requestPageCache;
 
     private final ActionRenderResponseGenerator generator;
 
-    public StringResultProcessor(RequestPageCache requestPageCache, ActionRenderResponseGenerator
generator)
+    public PageNameComponentEventResultProcessor(RequestPageCache requestPageCache,
+                                                 ActionRenderResponseGenerator generator)
     {
         this.requestPageCache = requestPageCache;
         this.generator = generator;
@@ -41,5 +42,4 @@
 
         generator.generateResponse(page);
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Fri Oct 31 13:54:25 2008
@@ -1322,9 +1322,7 @@
             @InjectService("ComponentInstanceResultProcessor")
             ComponentEventResultProcessor componentInstanceProcessor,
 
-            ComponentClassResolver componentClassResolver,
-
-            final RequestPageCache requestPageCache,
+            ObjectLocator locator,
 
             MappedConfiguration<Class, ComponentEventResultProcessor> configuration)
     {
@@ -1344,24 +1342,27 @@
             }
         });
 
-        configuration.add(String.class, new StringResultProcessor(requestPageCache, actionRenderResponseGenerator));
+        configuration.add(String.class, locator.autobuild(PageNameComponentEventResultProcessor.class));
 
-        configuration.add(Class.class, new ClassResultProcessor(componentClassResolver, requestPageCache,
-                                                                actionRenderResponseGenerator));
+        configuration.add(Class.class, locator.autobuild(ClassResultProcessor.class));
 
         configuration.add(Component.class, componentInstanceProcessor);
 
-        configuration.add(StreamResponse.class, new StreamResponseResultProcessor(response));
+        configuration.add(StreamResponse.class, locator.autobuild(StreamResponseResultProcessor.class));
     }
 
 
     /**
      * Contributes handlers for the following types: <dl> <dt>Object</dt>
<dd>Failure case, added to provide more useful
      * exception message</dd> <dt>{@link RenderCommand}</dt> <dd>Typically,
a {@link org.apache.tapestry5.Block}</dd>
-     * <dt>{@link Component}</dt> <dd>Renders the component and its body</dd>
<dt>{@link
-     * org.apache.tapestry5.json.JSONObject} or {@link org.apache.tapestry5.json.JSONArray}</dt>
<dd>The JSONObject is
-     * returned as a text/javascript response</dd> <dt>{@link org.apache.tapestry5.StreamResponse}</dt>
<dd>The stream
-     * response is sent as the actual response</dd> </dl>
+     * <dt>{@link org.apache.tapestry5.annotations.Component}</dt> <dd>Renders
the component and its body (unless its a
+     * page, in which case a redirect JSON response is sent)</dd> <dt>{@link
org.apache.tapestry5.json.JSONObject} or
+     * {@link org.apache.tapestry5.json.JSONArray}</dt> <dd>The JSONObject is
returned as a text/javascript
+     * response</dd> <dt>{@link org.apache.tapestry5.StreamResponse}</dt>
<dd>The stream response is sent as the actual
+     * response</dd> <dt>String</dt> <dd>Interprets the value as
a logical page name and sends a client response to
+     * redirect to that page</dd> <dt>{@link org.apache.tapestry5.Link}</dt>
<dd>Sends a JSON response to redirect to
+     * the link</dd> <dt>{@link Class}</dt> <dd>Treats the class
as a page class and sends a redirect for a page render
+     * for that page</dd> </dl>
      */
 
     public void contributeAjaxComponentEventResultProcessor(
@@ -1372,6 +1373,9 @@
         configuration.add(JSONObject.class, locator.autobuild(JSONObjectEventResultProcessor.class));
         configuration.add(JSONArray.class, locator.autobuild(JSONArrayEventResultProcessor.class));
         configuration.add(StreamResponse.class, new StreamResponseResultProcessor(response));
+        configuration.add(String.class, locator.autobuild(AjaxPageNameComponentEventResultProcessor.class));
+        configuration.add(Link.class, locator.autobuild(AjaxLinkComponentEventResultProcessor.class));
+        configuration.add(Class.class, locator.autobuild(AjaxPageClassComponentEventResultProcessor.class));
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java
Fri Oct 31 13:54:25 2008
@@ -1165,4 +1165,9 @@
     {
         expect(source.createEditModel(beanClass, messages)).andReturn(model);
     }
+
+    protected final ComponentEventResultProcessor mockComponentEventResultProcessor()
+    {
+        return newMock(ComponentEventResultProcessor.class);
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
Fri Oct 31 13:54:25 2008
@@ -1270,9 +1270,19 @@
      */
     processReply : function(reply)
     {
-        this.show(reply.content);
+        var redirect = reply.redirectURL;
 
-        Tapestry.processScriptInReply(reply);
+        if (redirect)
+        {
+            window.location.pathname = redirect;
+        }
+        else
+        {
+
+            this.show(reply.content);
+
+            Tapestry.processScriptInReply(reply);
+        }
     },
 
     /** Initiates an Ajax request to update this zone by sending a request

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/nested/ZoneDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/nested/ZoneDemo.tml?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/nested/ZoneDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/nested/ZoneDemo.tml Fri Oct 31 13:54:25
2008
@@ -60,7 +60,9 @@
         <li>
             <t:actionlink t:id="fail" zone="output">Failure on the server side</t:actionlink>
         </li>
-
+        <li>
+            <t:actionlink t:id="redirect" zone="output">Perform a redirect to another
page</t:actionlink>
+        </li>
     </ul>
 
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
Fri Oct 31 13:54:25 2008
@@ -2422,4 +2422,16 @@
 
         assertText("visiblepassword", "secret");
     }
+
+    /**
+     * TAP5-187
+     */
+    public void zone_redirect_by_class()
+    {
+        start("Zone Demo");
+
+        clickAndWait("link=Perform a redirect to another page");
+
+        assertText("activePageName", "nested/AssetDemo");
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/ZoneDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/ZoneDemo.java?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/ZoneDemo.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/ZoneDemo.java
Fri Oct 31 13:54:25 2008
@@ -123,4 +123,9 @@
     void onSelectedFromVoteNo() { vote = "No"; }
 
     Object onSuccessFromVote() { return voteOutput; }
+
+    Object onActionFromRedirect()
+    {
+        return AssetDemo.class;
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessorTest.java?rev=709564&r1=709563&r2=709564&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessorTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AjaxComponentInstanceEventResultProcessorTest.java
Fri Oct 31 13:54:25 2008
@@ -36,21 +36,24 @@
         Page page = mockPage();
         ComponentResources resources = mockComponentResources();
         Component component = mockComponent();
+        Component pageComponent = mockComponent();
+
         ComponentPageElement element = mockComponentPageElement();
-        PageRenderQueue queue = mockPageRenderQueue();
+        ComponentEventResultProcessor master = mockComponentEventResultProcessor();
 
         train_getComponentResources(component, resources);
+        train_getPage(resources, pageComponent);
         train_getPageName(resources, pageName);
         train_get(cache, pageName, page);
         train_getNestedId(resources, nestedId);
         train_getComponentElementByNestedId(page, nestedId, element);
 
-        queue.initializeForPartialPageRender(element);
+        master.processResultValue(element);
 
         replay();
 
         ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(
-                cache, queue);
+                cache, master);
 
         processor.processResultValue(component);
 
@@ -63,25 +66,22 @@
         String pageName = "Biff";
 
         RequestPageCache cache = mockRequestPageCache();
-        Page page = mockPage();
         ComponentResources resources = mockComponentResources();
         Component component = mockComponent();
-        ComponentPageElement element = mockComponentPageElement();
         PageRenderQueue queue = mockPageRenderQueue();
+        ComponentEventResultProcessor master = mockComponentEventResultProcessor();
 
         train_getComponentResources(component, resources);
+        train_getPage(resources, component);
         train_getPageName(resources, pageName);
-        train_get(cache, pageName, page);
-        train_getNestedId(resources, null);
-        train_getRootElement(page, element);
 
-        queue.initializeForPartialPageRender(element);
+        master.processResultValue(pageName);
 
         replay();
 
         ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(
                 cache,
-                queue);
+                master);
 
         processor.processResultValue(component);
 



Mime
View raw message