summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-06-07 14:02:38 +0000
committerLeif Åstrand <leif@vaadin.com>2012-06-07 14:02:38 +0000
commit07b20a1cd3118b744e361d02ca4a5607cccf124f (patch)
tree635078a5a40859ae1e357b2bcab4070d8643f061 /src
parent45b2a35ec9789bd1c6ef9cd46de3ba6695279547 (diff)
downloadvaadin-framework-07b20a1cd3118b744e361d02ca4a5607cccf124f.tar.gz
vaadin-framework-07b20a1cd3118b744e361d02ca4a5607cccf124f.zip
Prevent double iframe and script tags if writeAjaxPageScriptWidgetset is overridden (#8924)
svn changeset:23911/svn branch:6.8
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index 898bd2856c..edc151f22d 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -76,6 +76,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
private static final String PORTAL_PARAMETER_VAADIN_THEME = "vaadin.theme";
+ public static final String WRITE_AJAX_PAGE_SCRIPT_WIDGETSET_SHOULD_WRITE = "writeAjaxPageScriptWidgetsetShouldWrite";
+
// TODO some parts could be shared with AbstractApplicationServlet
// TODO Can we close the application when the portlet is removed? Do we know
@@ -1071,7 +1073,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
/**
* Writes the script to load the widgetset on the HTML fragment created by
- * the portlet.
+ * the portlet if the request attribute
+ * WRITE_AJAX_PAGE_SCRIPT_WIDGETSET_SHOULD_WRITE is set to Boolean.TRUE.
*
* @param request
* @param writer
@@ -1079,6 +1082,14 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
*/
protected void writeAjaxPageWidgetset(RenderRequest request,
BufferedWriter writer) throws IOException {
+ /*
+ * If the old method that used to add this code using document.write has
+ * been overridden, we shouldn't do anything here because then the
+ * iframe and script tag have already been added.
+ */
+ if (request.getAttribute(WRITE_AJAX_PAGE_SCRIPT_WIDGETSET_SHOULD_WRITE) != Boolean.TRUE) {
+ return;
+ }
String widgetsetURL = getWidgetsetURL(request);
writer.write("<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" "
+ "style=\"position:absolute;width:0;height:0;border:0;overflow:"
@@ -1108,6 +1119,14 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
// But we still need to close this one block, for compatibility
writer.append("\n}\n");
+
+ /*
+ * Set a flag so writeAjaxPageScriptWidgetset() knows that this method
+ * has not generated the old document.write code (happens if this method
+ * is overridden).
+ */
+ request.setAttribute(WRITE_AJAX_PAGE_SCRIPT_WIDGETSET_SHOULD_WRITE,
+ Boolean.TRUE);
}
/**