您是否需要自定义窗口小部件集?如果您没有使用任何窗口小部件插件,并且由于您是Vaadin的新手,我假设您尚未创建自己的窗口小部件(?),则可以简单地使用Vaadin提供的预编译窗口小部件集。为此,请从您的项目中删除任何xxx.gwt.xml文件,并用com.vaadin.DefaultWidgetset替换web.xml中对此文件的引用。
web.xml:
<init-param> <name>widgetset</name> <value>com.vaadin.DefaultWidgetSet</value></init-param>
pom.xml:
<dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client-compiled</artifactId> <version>7.1.9</version> <!-- or whatever version you're using --></dependency>
如果您确实需要自定义的小部件集(并且现在不需要的话,很可能您将需要一个进一步的小工具集),请帮个忙并将其放在单独的项目中。以我的经验,widgetset很少更改,因此为什么要将其包含在不断变化的项目中。Vaadin提供的上述默认小部件集是构建一个小部件的完美蓝图。只需构建自己的文件,然后从vaadin-
client-
compiled.jar复制其结构即可。您可以使用自己喜欢的Maven构建帮助器,即我的装配体。只需创建一个maven项目,设置pom.xml,添加xxx.gwt.xml并确保web.xml包含对该项目的引用。我自己的设置类似于您在下面看到的内容。
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <name>MyWidgetset</name> <groupId>com.company</groupId> <artifactId>mywidgetset</artifactId> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <vaadin.version>7.1.9</vaadin.version> <vaadin.plugin.version>7.1.9</vaadin.plugin.version> </properties> <dependencies> <!-- vaadin --> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client</artifactId> <version>${vaadin.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client-compiler</artifactId> <version>${vaadin.version}</version> <scope>provided</scope> </dependency> <!-- custom widgets (NOTE: addons without a widget do not belong here) --> <dependency> <groupId>org.vaadin.addons</groupId> <artifactId>filteringtable</artifactId> <version>0.9.3.v7</version> </dependency> <dependency> <groupId>org.vaadin.addons</groupId> <artifactId>popupbutton</artifactId> <version>2.3.0</version> </dependency> </dependencies> <build> <plugins> <!-- vaadin update widgetset --> <plugin> <groupId>com.vaadin</groupId> <artifactId>vaadin-maven-plugin</artifactId> <version>${vaadin.plugin.version}</version> <configuration> <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs> <webappDirectory>${basedir}/target/VAADIN/widgetsets</webappDirectory> <hostedWebapp>${basedir}/target/VAADIN/widgetsets</hostedWebapp> <force>false</force> <strict>true</strict> <noServer>true</noServer> <compileReport>true</compileReport> <style>OBF</style> <runTarget>http://localhost:8080/</runTarget> </configuration> <executions> <execution> <goals> <goal>resources</goal> <goal>update-widgetset</goal> <goal>compile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/resources/assembly.xml</descriptor> </descriptors> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <repositories> <repository> <id>vaadin-addons</id> <url>http://maven.vaadin.com/vaadin-addons</url> </repository> </repositories></project>assembly.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> <id>build-my-widgetset-jar</id> <formats> <format>jar</format> </formats> <includebaseDirectory>false</includebaseDirectory> <fileSets> <fileSet> <directory>${basedir}/target/VAADIN/widgetsets</directory> <outputDirectory>/VAADIN/widgetsets</outputDirectory> <excludes> <exclude>WEB-INF/</exclude> </excludes> </fileSet> </fileSets></assembly>MyWidgetset.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlepre.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd"><module> <inherits name="com.vaadin.DefaultWidgetSet" /> <inherits name="org.tepi.filtertable.gwt.FilterTableWidgetset" /> <inherits name="org.vaadin.hene.popupbutton.widgetset.PopupbuttonWidgetset" /></module>
web.xml:
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>MyWidgetset</display-name> <servlet> <servlet-name>MyWidgetset</servlet-name> <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> <init-param> <param-name>ui</param-name> <param-value>com.company.mywidgetset.App</param-value> <!-- use it for testing the widgetset--> </init-param> <init-param> <param-name>widgetset</param-name> <param-value>com.company.mywidgetset.MyWidgetset</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>MyWidgetset</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping></web-app>
项目结构:
| pom.xml|---src +---main | +---java | | ---com | | ---company | |---mywidgetset | | App.java | | MyWidgetset.gwt.xml | | | +---resources | | assembly.xml | | | ---webapp | ---WEB-INF | web.xml | ---test ---java
编译它,将jar用作项目中的依赖项,就可以完成了。这将使您永久摆脱GWT称为“ widgetset编译”的烦恼。



