You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/07/09 20:35:47 UTC

[1/2] git commit: WW-4352 Allows configure character encoding via param

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 <lu...@apache.org>
Authored: Wed Jul 9 20:30:41 2014 +0200
Committer: Lukasz Lenart <lu...@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();


[2/2] git commit: WW-4352 Adds description about new encoding param

Posted by lu...@apache.org.
WW-4352 Adds description about new encoding param


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

Branch: refs/heads/develop
Commit: fa814744dec32640bfe19444da250da7772a8079
Parents: e2b291f
Author: Lukasz Lenart <lu...@apache.org>
Authored: Wed Jul 9 20:35:34 2014 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Jul 9 20:35:34 2014 +0200

----------------------------------------------------------------------
 core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/fa814744/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 13e1629..7c3dd77 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
@@ -171,6 +171,7 @@ import java.util.Map;
  * <ul>
  *
  * <li><b>location (default)</b> - the location to go to after execution.</li>
+ * <li><b>encoding</b> - character encoding used in XML, default UTF-8.</li>
  *
  * <li><b>parse</b> - true by default. If set to false, the location param will
  * not be parsed for Ognl expressions.</li>