You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/09/23 19:01:20 UTC
svn commit: r1174885 - in
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5:
internal/services/HttpErrorComponentEventResultProcessor.java
services/HttpError.java services/TapestryModule.java
Author: hlship
Date: Fri Sep 23 17:01:19 2011
New Revision: 1174885
URL: http://svn.apache.org/viewvc?rev=1174885&view=rev
Log:
TAP5-1593: Type org.apache.tapestry5.services.HttpError should be an allowed return value from Ajax action requests
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/HttpErrorComponentEventResultProcessor.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/HttpError.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/HttpErrorComponentEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/HttpErrorComponentEventResultProcessor.java?rev=1174885&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/HttpErrorComponentEventResultProcessor.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/HttpErrorComponentEventResultProcessor.java Fri Sep 23 17:01:19 2011
@@ -0,0 +1,41 @@
+// Copyright 2011 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.ComponentEventResultProcessor;
+import org.apache.tapestry5.services.HttpError;
+import org.apache.tapestry5.services.Response;
+
+import java.io.IOException;
+
+/**
+ * Handles {@link HttpError} by invoking {@link Response#sendError(int, String)}.
+ *
+ * @since 5.3
+ */
+public class HttpErrorComponentEventResultProcessor implements ComponentEventResultProcessor<HttpError>
+{
+ private final Response response;
+
+ public HttpErrorComponentEventResultProcessor(Response response)
+ {
+ this.response = response;
+ }
+
+ public void processResultValue(HttpError value) throws IOException
+ {
+ response.sendError(value.getStatusCode(), value.getMessage());
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/HttpError.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/HttpError.java?rev=1174885&r1=1174884&r2=1174885&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/HttpError.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/HttpError.java Fri Sep 23 17:01:19 2011
@@ -11,11 +11,12 @@
// 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.services;
/**
* An event handler method may return an instance of this class to send an error response to the client.
- *
+ *
* @since 5.2.0
*/
public final class HttpError
@@ -23,14 +24,14 @@ public final class HttpError
private final int statusCode;
private final String message;
-
+
public HttpError(int statusCode, String message)
{
this.statusCode = statusCode;
-
+
this.message = message;
}
-
+
/**
* Returns the error status code.
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=1174885&r1=1174884&r2=1174885&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 Sep 23 17:01:19 2011
@@ -1697,13 +1697,7 @@ public final class TapestryModule
}
});
- configuration.add(HttpError.class, new ComponentEventResultProcessor<HttpError>()
- {
- public void processResultValue(HttpError value) throws IOException
- {
- response.sendError(value.getStatusCode(), value.getMessage());
- }
- });
+ configuration.addInstance(HttpError.class, HttpErrorComponentEventResultProcessor.class);
configuration.addInstance(String.class, PageNameComponentEventResultProcessor.class);
@@ -1757,6 +1751,7 @@ public final class TapestryModule
configuration.addInstance(Link.class, AjaxLinkComponentEventResultProcessor.class);
configuration.addInstance(Class.class, AjaxPageClassComponentEventResultProcessor.class);
configuration.addInstance(MultiZoneUpdate.class, MultiZoneUpdateEventResultProcessor.class);
+ configuration.addInstance(HttpError.class, HttpErrorComponentEventResultProcessor.class);
}
/**
@@ -2876,4 +2871,5 @@ public final class TapestryModule
});
}
}
+
}