您好我使用导航窗口和类视图为我们的应用程序创建菜单栏它工作正常,但当我在菜单栏中添加子菜单时显示错误说
SEVERE: Terminal error:
java.lang.IllegalStateException: Composition root must be set to non-null value before the com.vaadin.incubator.spring.ui.Reference2 can be painted
at com.vaadin.ui.CustomComponent.paintContent(CustomComponent.java:125)
我的代码就像
for (final Class viewClass : new Class[] { Trade.class, Position.class,
Cash.class, Recon.class, Price.class, Accounting.class,
Reference.class, Report.class, }) {
navigator.addView(viewClass.getSimpleName(), viewClass);
if (viewClass.getSimpleName().equals("Price")) {
MenuBar.MenuItem Price = menu.addItem("Price", null);
for (final Class viewClasssubmenu : new Class[] {
PriceActivity.class, ViewPrice.class, }) {
navigator.addView(viewClasssubmenu.getSimpleName(),
viewClasssubmenu);
Price.addItem(viewClasssubmenu.getSimpleName(),
new MenuBar.Command() {
public void menuSelected(MenuItem selectedItem) {
// TODO Auto-generated method stub
navigator.navigateTo(viewClasssubmenu);
}
});
}
} else if (viewClass.getSimpleName().equals("Recon")) {
if (viewClass.getSimpleName().equals("Recon")) {
MenuBar.MenuItem Recon = menu.addItem("Recon", null);
for (final Class viewClasssubmenu : new Class[] {
Recon1.class, Recon2.class, }) {
navigator.addView(viewClasssubmenu.getSimpleName(),
viewClasssubmenu);
Recon.addItem(viewClasssubmenu.getSimpleName(),
new MenuBar.Command() {
public void menuSelected(
MenuItem selectedItem) {
// TODO Auto-generated method stub
navigator.navigateTo(viewClasssubmenu);
}
});
}
}
} else if (viewClass.getSimpleName().equals("Reference")) {
if (viewClass.getSimpleName().equals("Reference")) {
MenuBar.MenuItem Reference = menu
.addItem("Reference", null);
for (final Class viewClasssubmenu : new Class[] {
Reference1.class, Reference2.class, }) {
navigator.addView(viewClasssubmenu.getSimpleName(),
viewClasssubmenu);
Reference.addItem(viewClasssubmenu.getSimpleName(),
new MenuBar.Command() {
public void menuSelected(
MenuItem selectedItem) {
// TODO Auto-generated method stub
navigator.navigateTo(viewClasssubmenu);
}
});
}
}
} else {
menu.addItem(viewClass.getSimpleName(), new MenuBar.Command() {
public void menuSelected(MenuItem selectedItem) {
navigator.navigateTo(viewClass);
}
});
}
}
return w;
}
任何人帮助我在导航课程中如何添加子菜单项?如果你提供我的exaple它将对我有很大的帮助..
答案 0 :(得分:2)
这可能与菜单无关。该错误表示您已扩展的CustomComponent(即Vaadin语言中的“复合”)没有设置组合根组件。也许这是你的观点类之一?
无论如何,您应该在组件的构造函数中设置它,以确保在渲染时存在一个。有关详细信息和示例,请参阅此处:http://vaadin.com/book/-/page/components.customcomponent.html