Java Vaadin 6 至 7 升级

标签 java vaadin

尝试从 6 VAADIN 升级到 7 VAADIN 时出现以下错误。 我是 Java 和 Vaadin 的新手,任何帮助都会很好。 谢谢

描述资源路径位置类型 类型的 getMainWindow() 方法未定义

private void periodicRefresh() {
    // Logout if requested
    if (mKicker != null) {
        String kickMessage = KickoutMessageText + mKicker.getData().getName();
        mKicker = null;
        logoutCore();
        getMainWindow().showNotification(KickoutMessageTitle, kickMessage, Notification.TYPE_WARNING_MESSAGE);
    }

    // Refresh logged in users
    refreshLoggedInUsers();

    // Refresh GPIO pin states
    refreshGPIOPinStates();

}

第二个问题: 描述 资源路径 位置类型 new LoginForm.LoginListener() 类型的 getMainWindow() 方法未定义

也在相同的代码中 描述 资源路径 位置类型 对于面板类型,方法 addComponent(LoginForm) 未定义

    private void createLoginUI(final AbstractOrderedLayout parentLayout) {
    final Rpi_gpio_controllerApplication application = this;

    LoginForm loginForm = new LoginForm();
    loginForm.addListener(new LoginForm.LoginListener() {
        Rpi_gpio_controllerApplication mApplication = application;

        @Override
        public void onLogin(LoginEvent event) {
            String loginErrorMessage = new User(
                    new UserData(event.getLoginParameter("username"), event.getLoginParameter("password")),
                    mApplication).login();
            if (loginErrorMessage != null) {
                Notification notification = new Notification(LoginErrorMessage, loginErrorMessage,
                        Notification.TYPE_ERROR_MESSAGE);
                notification.setDelayMsec(1000);
                getMainWindow().showNotification(notification);
            }
        }
    });

    Panel loginPanel = new Panel("Log in!!!!");
    loginPanel.setWidth("200px");
    loginPanel.setHeight("250px");
    loginPanel.addComponent(loginForm);

    parentLayout.addComponent(loginPanel);
    parentLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

最佳答案

第一个通知以其他方式使用:

Notification.show(KickoutMessageTitle, kickMessage, Notification.TYPE_WARNING_MESSAGE);

第二个 - 6 中的面板具有默认内容,您可以向其中添加组件, 在版本 7 中,内容必须由您设置。

解决方案-创建一个布局(contentLayout)并使用setContent(contentLayout) 然后将其他组件添加到contentLayout

如果您需要在 vaadin 7 中获取窗口(如 getMainWindowMethod),您需要使用:

UI.getCurrent().getWindow()

编辑:

1:

private void periodicRefresh() {
// Logout if requested
if (mKicker != null) {
    String kickMessage = KickoutMessageText + mKicker.getData().getName();
    mKicker = null;
    logoutCore();
    Notification.show(KickoutMessageTitle, kickMessage, Notification.TYPE_WARNING_MESSAGE);
}

// Refresh logged in users
refreshLoggedInUsers();

// Refresh GPIO pin states
refreshGPIOPinStates();

}

2:

private void createLoginUI(final AbstractOrderedLayout parentLayout) {
final Rpi_gpio_controllerApplication application = this;

LoginForm loginForm = new LoginForm();
loginForm.addListener(new LoginForm.LoginListener() {
    Rpi_gpio_controllerApplication mApplication = application;

    @Override
    public void onLogin(LoginEvent event) {
        String loginErrorMessage = new User(
                new UserData(event.getLoginParameter("username"), event.getLoginParameter("password")),
                mApplication).login();
        if (loginErrorMessage != null) {
            Notification notification = new Notification(LoginErrorMessage, loginErrorMessage,
                    Notification.TYPE_ERROR_MESSAGE);
            notification.setDelayMsec(1000);
            notification.show(Page.getCurrent());
        }
    }
});

Panel loginPanel = new Panel("Log in!!!!");
loginPanel.setWidth("200px");
loginPanel.setHeight("250px");
loginPanel.setContent(loginForm);

parentLayout.addComponent(loginPanel);
parentLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);

}

关于Java Vaadin 6 至 7 升级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31497516/

相关文章:

java - Vaadin 从 RouterLayout 引用 mainLayout

javascript - 函数等待查询结果

java - 优先级队列不维护排序顺序

java - 文件操作在 Java Web Start 中不起作用

java - 获取当前值 URL?

security - 如何使用 Apache Shiro 处理分层角色/权限?

Java slider 循环

java - Android:如何在首选项上设置 OnPreferenceClickListener?

java - 如何在 Vaadin 10 中管理 session ?

java - 如何在 vaadin 7 中的两个表之间同步滚动?