diff options
author | Artur Signell <artur@vaadin.com> | 2016-09-15 10:43:27 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-09-25 15:30:41 +0300 |
commit | 092b4f7f3192555fe3ae22ac03a89ac2ada2a2dd (patch) | |
tree | ba28dd87b93b802ed0040f35f8fe2c7a636214a2 | |
parent | 41dc2fe1611adc70d00e6f77debb2a6d4dcdefb0 (diff) | |
download | vaadin-framework-092b4f7f3192555fe3ae22ac03a89ac2ada2a2dd.tar.gz vaadin-framework-092b4f7f3192555fe3ae22ac03a89ac2ada2a2dd.zip |
Use widget set specified by init parameter (#20276)
1. If a UI has @Widgetset, use that
2. If a "widgetset" init parameter has been specified, use that
3. If there is an AppWidgetset, use that
4. Use DefaultWidgetSet
This changes the default value of the @VaadinServletConfiguration widgetset
parameter to "", to avoid always setting the "widgetset" init parameter when
@VaadinServletConfiguration is used.
Change-Id: I87f9aa294d31e62bb94b7e831dd7b25ca1ce483b
3 files changed, 23 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/annotations/VaadinServletConfiguration.java b/server/src/main/java/com/vaadin/annotations/VaadinServletConfiguration.java index 4cc51815a0..5a5a9988c4 100644 --- a/server/src/main/java/com/vaadin/annotations/VaadinServletConfiguration.java +++ b/server/src/main/java/com/vaadin/annotations/VaadinServletConfiguration.java @@ -123,12 +123,15 @@ public @interface VaadinServletConfiguration { /** * The default widgetset to use for the servlet. The default value is - * <code>com.vaadin.DefaultWidgetSet</code>. + * <code>""</code>, which will cause + * <code>com.vaadin.DefaultWidgetSet</code> to be used unless overridden by + * an init parameter or unless an automatically generated + * <code>AppWidgetset</code> is used. * * @return the default widgetset name */ @InitParameterName(VaadinServlet.PARAMETER_WIDGETSET) - public String widgetset() default VaadinServlet.DEFAULT_WIDGETSET; + public String widgetset() default ""; /** * The legacy Property.toString() mode used. The default value is diff --git a/server/src/main/java/com/vaadin/server/UIProvider.java b/server/src/main/java/com/vaadin/server/UIProvider.java index e0222933d3..d16507234d 100644 --- a/server/src/main/java/com/vaadin/server/UIProvider.java +++ b/server/src/main/java/com/vaadin/server/UIProvider.java @@ -178,15 +178,22 @@ public abstract class UIProvider implements Serializable { return new WidgetsetInfoImpl(uiWidgetset.value()); } + // Second case: We might have an init parameter, use that + String initParameterWidgetSet = event.getService() + .getDeploymentConfiguration().getWidgetset(null); + if (initParameterWidgetSet != null) { + return new WidgetsetInfoImpl(initParameterWidgetSet); + } + // Find the class AppWidgetset in the default package if one exists WidgetsetInfo info = getWidgetsetClassInfo(); - // Second case: we have a generated class called APP_WIDGETSET_NAME + // Third case: we have a generated class called APP_WIDGETSET_NAME if (info != null) { return info; } - // third case: we have an AppWidgetset.gwt.xml file + // Fourth case: we have an AppWidgetset.gwt.xml file else { InputStream resource = event.getUIClass() .getResourceAsStream("/" + APP_WIDGETSET_NAME + ".gwt.xml"); diff --git a/server/src/main/java/com/vaadin/server/VaadinServlet.java b/server/src/main/java/com/vaadin/server/VaadinServlet.java index b48063f972..8409507846 100644 --- a/server/src/main/java/com/vaadin/server/VaadinServlet.java +++ b/server/src/main/java/com/vaadin/server/VaadinServlet.java @@ -268,6 +268,15 @@ public class VaadinServlet extends HttpServlet implements Constants { stringValue = value.toString(); } + if (VaadinServlet.PARAMETER_WIDGETSET.equals(name.value()) + && method.getDefaultValue().equals(stringValue)) { + // Do not set the widgetset to anything so that the + // framework can fallback to the default. Setting + // anything to the init parameter will force that into + // use and e.g. AppWidgetset will not be used even + // though it is found. + continue; + } initParameters.setProperty(name.value(), stringValue); } catch (Exception e) { // This should never happen |