zero_cool zero_cool - 4 months ago 45
Java Question

How to use Vaadin add-on with Spring Boot?

I'm using Vaadin 7.6.3 with Spring Boot. I'm trying to use the PopupButton add-on (but I don't think the issue is specific to the add-on).

I added the add-on as a dependency to gradle. This is the code for creating a PopupButton:

PopupButton btn = new PopupButton("Test Button");
btn.setContent(new Label("Test"));
layout.addComponent(btn);


Via the Vaadin plugin for Gradle I ran the task
vaadinCompile
which created the file
src/main/resources/addon/client/ListaideWidgetset.gwt.xml
and serveral files in
src/main/webapp/VAADIN/gwt-unitCache
and
src/main/webapp/VAADIN/widgetsets/addon.client.ListaideWidgetset
. I also added
@Widgetset("addon.client.ListaideWidgetset")
to my UI. I confirmed that the widgetset is used via the client's
?debug
mode.

Content of
ListaideWidgetset.gwt.xml
:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Vaadin//DTD Vaadin 7//EN" "https://raw.github.com/vaadin/gwt/master/distro-source/core/src/gwt-module.dtd">
<!-- WS Compiler: manually edited -->
<module>
<inherits name="com.vaadin.DefaultWidgetSet" />
<set-configuration-property name="devModeRedirectEnabled" value="true" />
<set-property name="user.agent" value="ie8,ie9,gecko1_8,safari,ie10" />
<source path="client" />
<source path="shared" />
<collapse-all-properties />
<set-property name="compiler.useSymbolMaps" value="true" />
</module>


The problem is that on the client the button shows up as a standard button (no chevron) and doesn't open a popup when clicked.

Answer

Your widgetset does not contain the addon. See the the example:

 <inherits name="org.vaadin.hene.popupbutton.widgetset.PopupbuttonWidgetset" />

Once added, recompile the widgetset, restart your application.

Usually the gradle plugin can handle this for you, but that feature can be disabled and or some other configuration error could prevent it. Hard to tell without the build.gradle...

edit

The gradle vaadin plugin seems not to be able to handle this addon properly. As a workaround disable the automatic management for widgetset, which prevents regeneration of the gwt.xml. See manageWidgetset in https://github.com/johndevs/gradle-vaadin-plugin/wiki/Tasks-and-configuration-DSL). E.g. add vaadinCompile.manageWidgetset = false in your vaadin{}-block.