diff options
author | Artur Signell <artur.signell@itmill.com> | 2008-09-01 05:23:15 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2008-09-01 05:23:15 +0000 |
commit | f1871b8525ad36aa66110b4911dd1a2595c9c9a0 (patch) | |
tree | bb24248d4aaf24422b60e5ce7d493e39f4c5ee41 /src | |
parent | f6b7e02013458950bc93c23993a1585496a0ab16 (diff) | |
download | vaadin-framework-f1871b8525ad36aa66110b4911dd1a2595c9c9a0.tar.gz vaadin-framework-f1871b8525ad36aa66110b4911dd1a2595c9c9a0.zip |
Fixes #2022 - UTF-8 is now always used for custom layouts
svn changeset:5310/svn branch:trunk
Diffstat (limited to 'src')
3 files changed, 48 insertions, 15 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index 559dda6e81..f7789fefc9 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -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 index 0000000000..1e133f8b4b --- /dev/null +++ b/src/com/itmill/toolkit/tests/tickets/Ticket2022.java @@ -0,0 +1,31 @@ +package com.itmill.toolkit.tests.tickets;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.ui.CustomLayout;
+import com.itmill.toolkit.ui.Window;
+
+public class Ticket2022 extends Application {
+
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ setTheme("tests-tickets");
+ CustomLayout l;
+
+ // WebApplicationContext wac = ((WebApplicationContext) getContext());
+ // File f = new File(wac.getBaseDirectory().getAbsoluteFile()
+ // + "/ITMILL/themes/" + getTheme() + "/layouts/Ticket2022.html");
+
+ l = new CustomLayout("Ticket2022");
+ // try {
+ // l = new CustomLayout(new FileInputStream(f));
+ w.setLayout(l);
+ // } catch (FileNotFoundException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // } catch (IOException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ }
+}
diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java index 0cb8851202..06ef2923ea 100644 --- a/src/com/itmill/toolkit/ui/CustomLayout.java +++ b/src/com/itmill/toolkit/ui/CustomLayout.java @@ -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); |