Browse Source

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
tags/7.7.3
Artur Signell 7 years ago
parent
commit
092b4f7f31

+ 5
- 2
server/src/main/java/com/vaadin/annotations/VaadinServletConfiguration.java View File

@@ -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

+ 9
- 2
server/src/main/java/com/vaadin/server/UIProvider.java View File

@@ -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");

+ 9
- 0
server/src/main/java/com/vaadin/server/VaadinServlet.java View File

@@ -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

Loading…
Cancel
Save