summaryrefslogtreecommitdiffstats
path: root/server/src/com
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-06-11 20:35:04 +0300
committerArtur Signell <artur@vaadin.com>2014-06-26 11:11:47 +0000
commit1b73b00b2875c5eafa3c641b77f5d9efc2f7d929 (patch)
treed41b978f8e58f3d294e46e88567e448b47fee450 /server/src/com
parent949fb45841374204307b50f48d0d2d9ab921deb6 (diff)
downloadvaadin-framework-1b73b00b2875c5eafa3c641b77f5d9efc2f7d929.tar.gz
vaadin-framework-1b73b00b2875c5eafa3c641b77f5d9efc2f7d929.zip
Allow changing theme on the fly (#2874)
Change-Id: I70c153c4109428686002f985bfe1cb7cba2c9b31
Diffstat (limited to 'server/src/com')
-rw-r--r--server/src/com/vaadin/ui/UI.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index a72cbe5c30..4bde8a95b3 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -549,8 +549,6 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private boolean resizeLazy = false;
- private String theme;
-
private Navigator navigator;
private PushConnection pushConnection = null;
@@ -633,7 +631,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
this.embedId = embedId;
// Actual theme - used for finding CustomLayout templates
- theme = request.getParameter("theme");
+ getState(false).theme = request.getParameter("theme");
getPage().init(request);
@@ -1135,12 +1133,31 @@ public abstract class UI extends AbstractSingleComponentContainer implements
}
/**
- * Gets the theme that was used when the UI was initialized.
+ * Gets the theme currently in use by this UI
*
* @return the theme name
*/
public String getTheme() {
- return theme;
+ return getState(false).theme;
+ }
+
+ /**
+ * Sets the theme currently in use by this UI
+ * <p>
+ * Calling this method will remove the old theme (CSS file) from the
+ * application and add the new theme.
+ * <p>
+ * Note that this method is NOT SAFE to call in a portal environment or
+ * other environment where there are multiple UIs on the same page. The old
+ * CSS file will be removed even if there are other UIs on the page which
+ * are still using it.
+ *
+ * @since
+ * @param theme
+ * The new theme name
+ */
+ public void setTheme(String theme) {
+ getState().theme = theme;
}
/**