You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2008/03/23 02:42:09 UTC
svn commit: r640128 -
/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java
Author: ivaynberg
Date: Sat Mar 22 18:41:55 2008
New Revision: 640128
URL: http://svn.apache.org/viewvc?rev=640128&view=rev
Log:
WICKET-1420: allow custom content types for string request target
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java?rev=640128&r1=640127&r2=640128&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java Sat Mar 22 18:41:55 2008
@@ -24,6 +24,7 @@
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.util.io.Streams;
import org.apache.wicket.util.resource.StringBufferResourceStream;
+import org.apache.wicket.util.string.Strings;
/**
@@ -36,22 +37,44 @@
/** the string for the response. */
private final String string;
+ /** content type for the string */
+ private final String contentType;
+
/**
- * Construct.
+ * Constructor
*
* @param string
* the string for the response
*/
public StringRequestTarget(String string)
{
+ this("text", string);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param contentType
+ * content type of the data the string represents eg
+ * <code>text/html; charset=utf-8</code>
+ * @param string
+ * string for the response
+ */
+ public StringRequestTarget(String contentType, String string)
+ {
if (string == null)
{
throw new IllegalArgumentException("Argument string must be not null");
}
-
+ if (Strings.isEmpty(contentType))
+ {
+ throw new IllegalArgumentException("Argument contentType must not be null or empty");
+ }
+ this.contentType = contentType;
this.string = string;
}
+
/**
* Responds by sending the string property.
*
@@ -61,7 +84,7 @@
{
// Get servlet response to use when responding with resource
final Response response = requestCycle.getResponse();
- final StringBufferResourceStream stream = new StringBufferResourceStream();
+ final StringBufferResourceStream stream = new StringBufferResourceStream(contentType);
stream.append(string);
// Respond with resource