扩展Vaadin小部件

Iur*_*ban 4 java widget vaadin

我试图在Vaadin中扩展树组件.所以我创建了客户端类:

import com.vaadin.terminal.gwt.client.ui.VTree;
public class CustomVtree extends VTree {
}
Run Code Online (Sandbox Code Playgroud)

服务器端类:

import com.vaadin.ui.ClientWidget;
import com.vaadin.ui.Tree;
@ClientWidget(CustomVtree.class)
public class MyTree extends Tree {
    public MyTree() {
        super();
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到了 [WARN] Widget class com.vaadin.sample.gwt.client.ui.CustomVtree was not found. The component com.vaadin.sample.gwt.client.ui.MyTree will not be included in the widgetset. 什么,我忘了做什么或我做错了什么?很高兴得到任何帮助.谢谢

Hen*_*ola 6

您的类看起来正确但缺少一件事:GWT模块描述符文件.将该文件添加到com.vaadin.sample.gwt包中,在此我称之为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.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
    <inherits name="com.vaadin.terminal.gwt.DefaultWidgetSet" />
</module>
Run Code Online (Sandbox Code Playgroud)

然后你必须在web.xml中定义你想要使用这个widgetset:

<init-param>
    <description>Application widgetset</description>
    <param-name>widgetset</param-name>
    <param-value>com.vaadin.sample.gwt.MyWidgetset</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)

完成这些步骤后,GWT编译应该可以正常工作.