vaadin子菜单添加问题

发布于 2024-11-26 16:34:12 字数 3661 浏览 1 评论 0原文

您好,我正在使用导航窗口和类视图为我们的应用程序创建菜单栏,它工作正常,但是当我在菜单栏中添加子菜单时,它显示错误,说

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;
}

任何人都可以帮助我在导航类视图中如何添加子菜单项?如果你给我提供一个例子,这对我来说会有很大的帮助。

Hi I m using navigation window and class view to create menu bar for our application it works fine,but when i m added submenu inside the menu bar it showing error saying like

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)

my code is like

    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;
}

Any one help me out in navigation class viwes how to add submenu items ?if you provide me exaple it will be great help for me..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜光 2024-12-03 16:34:12

这可能与菜单无关。该错误表明您扩展了一个 CustomComponent(即 Vaadin 语言中的“复合”),但未设置组合根组件。也许这是您的视图类之一?

无论如何,您应该在组件的构造函数中设置它,以确保它在渲染时存在。有关详细信息和示例,请参阅此: http://vaadin.com/book/-/页面/components.customcomponent.html

This may not have anything to do with the menu. The error says that there is a CustomComponent (i.e. "composite" in Vaadin language) that you have extended that has not a set the composition root component. Maybe it is one of your view classes?

Anyway, you should set that in the constructor of the component to make sure that one exists on rendering time. See this for details and example: http://vaadin.com/book/-/page/components.customcomponent.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文