shale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject svn commit: r476661 - in /shale/framework/trunk: shale-apps/shale-usecases/src/main/java/org/apache/shale/usecases/remoting/ shale-remoting/src/main/java/org/apache/shale/remoting/faces/
Date Sat, 18 Nov 2006 23:44:11 GMT
Author: craigmcc
Date: Sat Nov 18 15:44:11 2006
New Revision: 476661

URL: http://svn.apache.org/viewvc?view=rev&rev=476661
Log:
Set the response character encoding on the ResponseWriter construted by
ResponseFactory, so that non-ASCII characters may be passed in the content.
Thanks to Shinsuke Sugaya for the patch.

SHALE-282

Modified:
    shale/framework/trunk/shale-apps/shale-usecases/src/main/java/org/apache/shale/usecases/remoting/Business.java
    shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/BasicResponseWriter.java
    shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/ResponseFactory.java

Modified: shale/framework/trunk/shale-apps/shale-usecases/src/main/java/org/apache/shale/usecases/remoting/Business.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-usecases/src/main/java/org/apache/shale/usecases/remoting/Business.java?view=diff&rev=476661&r1=476660&r2=476661
==============================================================================
--- shale/framework/trunk/shale-apps/shale-usecases/src/main/java/org/apache/shale/usecases/remoting/Business.java
(original)
+++ shale/framework/trunk/shale-apps/shale-usecases/src/main/java/org/apache/shale/usecases/remoting/Business.java
Sat Nov 18 15:44:11 2006
@@ -97,7 +97,7 @@
     protected void selectItems(FacesContext context, SelectItem items[]) throws IOException
{
 
         ResponseWriter writer =
-                (new ResponseFactory()).getResponseWriter(context, "text/xml");
+                (new ResponseFactory()).getResponseWriter(context, "text/xml; charset=UTF-8");
 
         // Generate the response content
         writer.startDocument();

Modified: shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/BasicResponseWriter.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/BasicResponseWriter.java?view=diff&rev=476661&r1=476660&r2=476661
==============================================================================
--- shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/BasicResponseWriter.java
(original)
+++ shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/BasicResponseWriter.java
Sat Nov 18 15:44:11 2006
@@ -309,7 +309,7 @@
     private void numeric(Writer writer, char ch) throws IOException {
 
         writer.write("&#");
-        writer.write(String.valueOf(ch));
+        writer.write(String.valueOf((int) ch));
         writer.write(";");
 
     }

Modified: shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/ResponseFactory.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/ResponseFactory.java?view=diff&rev=476661&r1=476660&r2=476661
==============================================================================
--- shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/ResponseFactory.java
(original)
+++ shale/framework/trunk/shale-remoting/src/main/java/org/apache/shale/remoting/faces/ResponseFactory.java
Sat Nov 18 15:44:11 2006
@@ -190,11 +190,27 @@
             throw new FacesException(e);
         }
 
+        // From JSF 1.2 on, we can call ExternalContext.getResponseCharacterEncoding(),
+        // but for JSF 1.1 we must use response.getCharacterEncoding() instead
+        String encoding = null;
+        try {
+            String methodName = "getCharacterEncoding";
+            Method method =
+                response.getClass().getMethod(methodName, new Class[] { });
+            encoding = (String) method.invoke(response, new Object[] { });
+        } catch (IllegalAccessException e) {
+            throw new FacesException(e);
+        } catch (InvocationTargetException e) {
+            throw new FacesException(e);
+        } catch (NoSuchMethodException e) {
+            throw new FacesException(e);
+        }
+
         // Construct a ResponseWriter that wraps this stream
-        if ("text/html".equals(contentType)) {
-            return renderKit(context).createResponseWriter(writer, contentType, null);
+        if ((contentType != null) && contentType.startsWith("text/html")) {
+            return renderKit(context).createResponseWriter(writer, contentType, encoding);
         } else {
-            return new BasicResponseWriter(writer, contentType, null);
+            return new BasicResponseWriter(writer, contentType, encoding);
         }
 
 



Mime
View raw message