gpt4 book ai didi

Java Vaadin 6 至 7 升级

转载 作者:行者123 更新时间:2023-12-01 11:18:46 24 4
gpt4 key购买 nike

尝试从 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com