From: Artur Signell Date: Thu, 15 Sep 2016 07:43:27 +0000 (+0300) Subject: Use widget set specified by init parameter (#20276) X-Git-Tag: 7.7.3~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=092b4f7f3192555fe3ae22ac03a89ac2ada2a2dd;p=vaadin-framework.git 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 --- 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 - * com.vaadin.DefaultWidgetSet. + * "", which will cause + * com.vaadin.DefaultWidgetSet to be used unless overridden by + * an init parameter or unless an automatically generated + * AppWidgetset 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