Repository: struts
Updated Branches:
  refs/heads/develop 9aedd857a -> fa814744d


WW-4352 Allows configure character encoding via param


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e2b291f8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e2b291f8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e2b291f8

Branch: refs/heads/develop
Commit: e2b291f8a7b061231e43ac78241fadf96f63c77f
Parents: 9aedd85
Author: Lukasz Lenart <lukaszlen...@apache.org>
Authored: Wed Jul 9 20:30:41 2014 +0200
Committer: Lukasz Lenart <lukaszlen...@apache.org>
Committed: Wed Jul 9 20:30:41 2014 +0200

----------------------------------------------------------------------
 .../java/org/apache/struts2/views/xslt/XSLTResult.java   | 11 +++++++++++
 .../org/apache/struts2/views/xslt/XSLTResultTest.java    | 11 +++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/e2b291f8/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java 
b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java
index 42b916b..13e1629 100644
--- a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java
+++ b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java
@@ -241,6 +241,8 @@ public class XSLTResult implements Result {
     /** Indicates the status to return in the response */
     private int status = 200;
 
+    private String encoding = "UTF-8";
+
     private boolean parse;
     private AdapterFactory adapterFactory;
 
@@ -322,6 +324,14 @@ public class XSLTResult implements Result {
         }
     }
 
+    public String getEncoding() {
+        return encoding;
+    }
+
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
+
     /**
      * If true, parse the stylesheet location for OGNL expressions.
      *
@@ -344,6 +354,7 @@ public class XSLTResult implements Result {
         try {
             HttpServletResponse response = ServletActionContext.getResponse();
             response.setStatus(status);
+            response.setCharacterEncoding(encoding);
             PrintWriter writer = response.getWriter();
 
             // Create a transformer for the stylesheet.

http://git-wip-us.apache.org/repos/asf/struts/blob/e2b291f8/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java 
b/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
index 6345ce3..c9fdadd 100644
--- a/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
+++ b/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
@@ -205,6 +205,17 @@ public class XSLTResultTest extends StrutsInternalTestCase 
{
         assertTrue(out.indexOf("<result 
xmlns=\"http://www.w3.org/TR/xhtml1/strict\"";) > -1);
     }
 
+    public void testEncoding() throws Exception {
+        result.setParse(false);
+        result.setLocation("XSLTResultTest.xsl");
+        result.setEncoding("ISO-8859-1");
+        result.execute(mai);
+
+        String actual = response.getCharacterEncoding();
+
+        assertEquals(actual, "ISO-8859-1");
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         request = new MockHttpServletRequest();

Reply via email to