2015-07-19 136 views
0

尝试从6升级到7 VAADIN获得以下错误。 我刚接触Java和Vaadin,任何帮助都不错。 感谢Java Vaadin 6到7升级

描述资源路径位置类型 方法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()是未定义的新类型LoginForm.LoginListener()

也使用相同的代码 描述资源路径位置类型 未定义方法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

1:

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

2日 - 面板6具有默认的内容,您可以在第7版的内容必须将组件添加到它, 由你设置。

解决方案 - 创建一个布局(contentLayout),并使用setContent(contentLayout) 然后如果你需要在vaadin 7得到一个窗口(如getMainWindowMethod)您需要使用添加其他组件到contentLayout

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

}

+0

所以它需要如:
UI.getCurrent()getWindows(); Notification.show(KickoutMessageTitle,kickMessage,Notification.Type.WARNING_MESSAGE); –

+0

你不需要调用getWindows()Notification.show ....就是你需要的。 – Athi

+0

你有一个布局(contentLayout)的好例子吗? –