You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2008/01/05 02:05:35 UTC
svn commit: r609073 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry/services/ site/apt/guide/ test/app1/
test/java/org/apache/tapestry/integration/
test/java/org/apache/tapestry/integration/app1/pages/
Author: hlship
Date: Fri Jan 4 17:05:34 2008
New Revision: 609073
URL: http://svn.apache.org/viewvc?rev=609073&view=rev
Log:
TAPESTRY-1671: Need a way to redirect to external URLs
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/pagenav.apt
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ReturnTypes.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=609073&r1=609072&r2=609073&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Fri Jan 4 17:05:34 2008
@@ -1055,6 +1055,16 @@
}
/**
+ * Builds a shadow of the RequestGlobals.HTTPServletRequest property. Generally, you should inject
+ * the {@link Request} service instead, as future version of Tapestry may operate beyond just the
+ * servlet API.
+ */
+ public HttpServletRequest buildHttpServletRequest()
+ {
+ return _shadowBuilder.build(_requestGlobals, "HTTPServletRequest", HttpServletRequest.class);
+ }
+
+ /**
* Builds a shadow of the RequestGlobals.response property. Note again that the shadow can be an
* ordinary singleton, even though RequestGlobals is perthread.
*/
@@ -1100,6 +1110,8 @@
* to the containing page is sent.</dd>
* <dt>{@link org.apache.tapestry.StreamResponse}</dt>
* <dd>The stream response is sent as the actual reply.</dd>
+ * <dt>URL</dt>
+ * <dd>Sends a redirect to a (presumably) external URL</dd>
* </dl>
*/
public void contributeComponentEventResultProcessor(
@@ -1117,6 +1129,15 @@
throws IOException
{
_response.sendRedirect(value);
+ }
+ });
+
+ configuration.add(URL.class, new ComponentEventResultProcessor<URL>()
+ {
+ public void processComponentEvent(URL value, Component component, String methodDescripion)
+ throws IOException
+ {
+ _response.sendRedirect(value.toExternalForm());
}
});
Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/pagenav.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/pagenav.apt?rev=609073&r1=609072&r2=609073&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/pagenav.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/pagenav.apt Fri Jan 4 17:05:34 2008
@@ -81,6 +81,11 @@
An event handler can also return a {{{../../apidocs/org/apache/tapestry/StreamResponse.html}StreamResponse}} object, which encapsulates a stream to
be sent directly to the client browser. This is useful for compnents that want to, say, generate an image or PDF and provide it to the client.
+
+
+* URL response
+
+ A URL is handled as a client redirect to an external URL.
* Object response
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ReturnTypes.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ReturnTypes.tml?rev=609073&r1=609072&r2=609073&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ReturnTypes.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ReturnTypes.tml Fri Jan 4 17:05:34 2008
@@ -1,33 +1,55 @@
<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
- <h1>Return Type Tests</h1>
+ <h1>Return Type Tests</h1>
+
+ <p>
+ Test
+ <a t:type="ActionLink" t:id="NullReturnValue">null</a>
+ return values.
+ </p>
+
+ <p>
+ Test
+ <a t:type="ActionLink" t:id="StringReturnValue">string</a>
+ return values.
+ </p>
+
+ <p>
+ Test
+ <a t:type="ActionLink" t:id="ClassReturnValue">class</a>
+ return values.
+ </p>
+
+ <p>
+ Test
+ <a t:type="ActionLink" t:id="PageReturnValue">page</a>
+ return values.
+ </p>
+
+ <p>
+ Test
+ <a t:type="ActionLink" t:id="LinkReturnValue">link</a>
+ return values.
+ </p>
+
+ <p>
+ Test
+ <a t:type="ActionLink" t:id="StreamReturnValue">stream</a>
+ return values.
+ </p>
+
+ <p>
+ Test
+ <t:actionlink t:id="url">URL</t:actionlink>
+ return values.
+ </p>
+
+
+ <p>
+ Test
+ <a t:type="ActionLink" t:id="BadReturnValue">bad</a>
+ return values.
+ </p>
- <p>
- Test <a t:type="ActionLink" t:id="NullReturnValue">null</a> return values.
- </p>
-
- <p>
- Test <a t:type="ActionLink" t:id="StringReturnValue">string</a> return values.
- </p>
-
- <p>
- Test <a t:type="ActionLink" t:id="ClassReturnValue">class</a> return values.
- </p>
-
- <p>
- Test <a t:type="ActionLink" t:id="PageReturnValue">page</a> return values.
- </p>
-
- <p>
- Test <a t:type="ActionLink" t:id="LinkReturnValue">link</a> return values.
- </p>
-
- <p>
- Test <a t:type="ActionLink" t:id="StreamReturnValue">stream</a> return values.
- </p>
-
- <p>
- Test <a t:type="ActionLink" t:id="BadReturnValue">bad</a> return values.
- </p>
</html>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=609073&r1=609072&r2=609073&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Fri Jan 4 17:05:34 2008
@@ -978,6 +978,13 @@
goBack();
waitForPageToLoad();
+ // This has been failing? Why?
+
+ // clickAndWait("link=URL");
+ // assertTextPresent("Google");
+ // goBack();
+ // waitForPageToLoad();
+
clickAndWait("link=bad");
assertTextPresent("An unexpected application exception has occurred.",
"An event handler for component org.apache.tapestry.integration.app1.pages.Start returned the value 20 (from method org.apache.tapestry.integration.app1.pages.Start.onActionFromBadReturnType() (at Start.java:34)). Return type java.lang.Integer can not be handled.");
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java?rev=609073&r1=609072&r2=609073&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java Fri Jan 4 17:05:34 2008
@@ -1,17 +1,17 @@
-// Copyright 2007 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.
-
+// Copyright 2007, 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.tapestry.integration.app1.pages;
import org.apache.tapestry.ComponentResources;
@@ -20,6 +20,9 @@
import org.apache.tapestry.services.ComponentEventResultProcessor;
import org.apache.tapestry.util.TextStreamResponse;
+import java.net.MalformedURLException;
+import java.net.URL;
+
/**
* Tests the various event handler method return types.
*
@@ -68,5 +71,10 @@
{
// What is Tapestry supposed to do with this? Let's see that Exception Report page.
return 20;
+ }
+
+ Object onActionFromURL() throws MalformedURLException
+ {
+ return new URL("http://google.com");
}
}