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/08/28 18:33:14 UTC

svn commit: r689875 - /wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java

Author: ivaynberg
Date: Thu Aug 28 09:33:13 2008
New Revision: 689875

URL: http://svn.apache.org/viewvc?rev=689875&view=rev
Log:
WICKET-1805

Modified:
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java?rev=689875&r1=689874&r2=689875&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/StringRequestTarget.java Thu Aug 28 09:33:13 2008
@@ -17,6 +17,7 @@
 package org.apache.wicket.request.target.basic;
 
 import java.io.OutputStream;
+import java.nio.charset.Charset;
 
 import org.apache.wicket.IRequestTarget;
 import org.apache.wicket.RequestCycle;
@@ -40,27 +41,35 @@
 	/** content type for the string */
 	private final String contentType;
 
+	/** charset of the string */
+	private final Charset charset;
+
+
 	/**
-	 * Constructor
+	 * Creates a string request target with content type <code>text/plain</code> and default charset
+	 * (usually UTF-8)
 	 * 
 	 * @param string
 	 *            the string for the response
 	 */
 	public StringRequestTarget(String string)
 	{
-		this("text/plain", string);
+		this("text/plain", Charset.defaultCharset(), string);
 	}
 
+
 	/**
 	 * Constructor
 	 * 
 	 * @param contentType
 	 *            content type of the data the string represents eg
 	 *            <code>text/html; charset=utf-8</code>
+	 * @param charset
+	 *            charset to use
 	 * @param string
 	 *            string for the response
 	 */
-	public StringRequestTarget(String contentType, String string)
+	public StringRequestTarget(String contentType, Charset charset, String string)
 	{
 		if (string == null)
 		{
@@ -70,8 +79,13 @@
 		{
 			throw new IllegalArgumentException("Argument contentType must not be null or empty");
 		}
+		if (charset == null)
+		{
+			throw new IllegalArgumentException("Argument charset must not be null");
+		}
 		this.contentType = contentType;
 		this.string = string;
+		this.charset = charset;
 	}
 
 
@@ -86,6 +100,7 @@
 		final Response response = requestCycle.getResponse();
 		response.setContentType(contentType);
 		final StringBufferResourceStream stream = new StringBufferResourceStream(contentType);
+		stream.setCharset(charset);
 		stream.append(string);
 
 		// Respond with resource