Java Vaadin 6到7升级

时间:2015-07-19 02:45:06

标签: java vaadin

尝试从6升级到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();

}

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

也在同一个代码中 描述资源路径位置类型 对于类型Panel

,方法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);
}

1 个答案:

答案 0 :(得分:1)

第1次通知以其他方式使用:

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

第2页 - 6中的面板有默认内容,你可以添加组件, 在版本7中,内容必须由您设置。

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

如果你需要在vaadin 7中获得一个Window(比如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);

}