2012-02-22 85 views
4

我想在Vaadin中扩展树组件。因此,我创建客户端类如:延伸Vaadin部件

import com.vaadin.terminal.gwt.client.ui.VTree; 
public class CustomVtree extends VTree { 
} 

服务器端类:

import com.vaadin.ui.ClientWidget; 
import com.vaadin.ui.Tree; 
@ClientWidget(CustomVtree.class) 
public class MyTree extends Tree { 
    public MyTree() { 
     super(); 
    } 
} 

而且我得到了 [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. 我忘记什么做的还是什么,我做错了什么?对任何帮助感到高兴。谢谢

+0

Сonnector不需要创建? – Alex78191 2018-02-28 12:22:29

回答

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> 

然后你必须在web.xml中定义要使用这个视窗元件:

<init-param> 
    <description>Application widgetset</description> 
    <param-name>widgetset</param-name> 
    <param-value>com.vaadin.sample.gwt.MyWidgetset</param-value> 
</init-param> 

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

1

什么是包声明?

在扩展客户端组件,客户端类应在

yourpackage.widgetset.client.ui

编译时,这个包扫描,以发现任何部件并将其添加到您的视窗元件。

然后你必须修改你的web.xml来改变init-param标签。

这里一BREF简历,以帮助您:Creating a widget