2015-07-19 170 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)的好例子嗎? –