]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #2022 - UTF-8 is now always used for custom layouts
authorArtur Signell <artur.signell@itmill.com>
Mon, 1 Sep 2008 05:23:15 +0000 (05:23 +0000)
committerArtur Signell <artur.signell@itmill.com>
Mon, 1 Sep 2008 05:23:15 +0000 (05:23 +0000)
svn changeset:5310/svn branch:trunk

WebContent/ITMILL/themes/tests-tickets/layouts/Ticket2022.html [new file with mode: 0644]
src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
src/com/itmill/toolkit/tests/tickets/Ticket2022.java [new file with mode: 0644]
src/com/itmill/toolkit/ui/CustomLayout.java

diff --git a/WebContent/ITMILL/themes/tests-tickets/layouts/Ticket2022.html b/WebContent/ITMILL/themes/tests-tickets/layouts/Ticket2022.html
new file mode 100644 (file)
index 0000000..4305481
--- /dev/null
@@ -0,0 +1,2 @@
+<div>This is an utf-8 string: åäöéèáèë<br/>
+The same in ISO-8859-1: åäöéèáèë</div>\r
index 559dda6e81db2c3a6fe280e36fa0bae9f2d62a80..f7789fefc91e0967e9e40a92c306e526fda71d92 100644 (file)
@@ -446,7 +446,8 @@ public class CommunicationManager implements Paintable.RepaintRequestListener {
                     final StringBuffer layout = new StringBuffer();
 
                     try {
-                        final InputStreamReader r = new InputStreamReader(is);
+                        final InputStreamReader r = new InputStreamReader(is,
+                                "UTF-8");
                         final char[] buffer = new char[20000];
                         int charsRead = 0;
                         while ((charsRead = r.read(buffer)) > 0) {
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2022.java b/src/com/itmill/toolkit/tests/tickets/Ticket2022.java
new file mode 100644 (file)
index 0000000..1e133f8
--- /dev/null
@@ -0,0 +1,31 @@
+package com.itmill.toolkit.tests.tickets;\r
+\r
+import com.itmill.toolkit.Application;\r
+import com.itmill.toolkit.ui.CustomLayout;\r
+import com.itmill.toolkit.ui.Window;\r
+\r
+public class Ticket2022 extends Application {\r
+\r
+    public void init() {\r
+        Window w = new Window(getClass().getSimpleName());\r
+        setMainWindow(w);\r
+        setTheme("tests-tickets");\r
+        CustomLayout l;\r
+\r
+        // WebApplicationContext wac = ((WebApplicationContext) getContext());\r
+        // File f = new File(wac.getBaseDirectory().getAbsoluteFile()\r
+        // + "/ITMILL/themes/" + getTheme() + "/layouts/Ticket2022.html");\r
+\r
+        l = new CustomLayout("Ticket2022");\r
+        // try {\r
+        // l = new CustomLayout(new FileInputStream(f));\r
+        w.setLayout(l);\r
+        // } catch (FileNotFoundException e) {\r
+        // // TODO Auto-generated catch block\r
+        // e.printStackTrace();\r
+        // } catch (IOException e) {\r
+        // // TODO Auto-generated catch block\r
+        // e.printStackTrace();\r
+        // }\r
+    }\r
+}\r
index 0cb8851202e89596f278eda1d728b5bf7c49c996..06ef2923eaa3cb0a53be914057e0533f3354f9e2 100644 (file)
@@ -57,16 +57,17 @@ public class CustomLayout extends AbstractLayout {
      * Constructs a custom layout with the template given in the stream.
      * 
      * @param templateStream
-     *                Stream containing template data. Must be using UTF-8
-     *                encoding. To use a String as a template use for instance
-     *                new ByteArrayInputStream("<template>".getBytes()).
+     *            Stream containing template data. Must be using UTF-8 encoding.
+     *            To use a String as a template use for instance new
+     *            ByteArrayInputStream("<template>".getBytes()).
      * @param streamLength
-     *                Length of the templateStream
+     *            Length of the templateStream
      * @throws IOException
      */
     public CustomLayout(InputStream templateStream) throws IOException {
 
-        InputStreamReader reader = new InputStreamReader(templateStream);
+        InputStreamReader reader = new InputStreamReader(templateStream,
+                "UTF-8");
         StringBuffer b = new StringBuffer(BUFFER_SIZE);
 
         char[] cbuf = new char[BUFFER_SIZE];
@@ -105,9 +106,9 @@ public class CustomLayout extends AbstractLayout {
      * is already populated, the old component is removed.
      * 
      * @param c
-     *                the component to be added.
+     *            the component to be added.
      * @param location
-     *                the location of the component.
+     *            the location of the component.
      */
     public void addComponent(Component c, String location) {
         final Component old = (Component) slots.get(location);
@@ -127,7 +128,7 @@ public class CustomLayout extends AbstractLayout {
      * components into that location overwrites the old components.
      * 
      * @param c
-     *                the component to be added.
+     *            the component to be added.
      */
     public void addComponent(Component c) {
         this.addComponent(c, "");
@@ -137,7 +138,7 @@ public class CustomLayout extends AbstractLayout {
      * Removes the component from this container.
      * 
      * @param c
-     *                the component to be removed.
+     *            the component to be removed.
      */
     public void removeComponent(Component c) {
         if (c == null) {
@@ -153,7 +154,7 @@ public class CustomLayout extends AbstractLayout {
      * Removes the component from this container from given location.
      * 
      * @param location
-     *                the Location identifier of the component.
+     *            the Location identifier of the component.
      */
     public void removeComponent(String location) {
         this.removeComponent((Component) slots.get(location));
@@ -173,8 +174,8 @@ public class CustomLayout extends AbstractLayout {
      * Gets the child-component by its location.
      * 
      * @param location
-     *                the name of the location where the requested component
-     *                resides.
+     *            the name of the location where the requested component
+     *            resides.
      * @return the Component in the given location or null if not found.
      */
     public Component getComponent(String location) {
@@ -186,7 +187,7 @@ public class CustomLayout extends AbstractLayout {
      * 
      * @param target
      * @throws PaintException
-     *                 if the paint operation failed.
+     *             if the paint operation failed.
      */
     public void paintContent(PaintTarget target) throws PaintException {
         super.paintContent(target);
@@ -245,7 +246,7 @@ public class CustomLayout extends AbstractLayout {
      * setStyle. Overriding to improve backwards compatibility.
      * 
      * @param name
-     *                template name
+     *            template name
      */
     public void setStyle(String name) {
         setTemplateName(name);