你好嗎?我有一個推一個細節更新,其中包含我的網格選項卡之後,我使用vaadin 8.0.4 ,谷歌Chrome更新,我的例子在這裏基於https://github.com/vaadin/archetype-application-exampleVaadin - grid.getDataProvider()。refreshAll();更新瀏覽器後不起作用
我的應用程序由存儲在MongoDB中的數據,當我在數據庫中每隔30秒用一次推送就直接更改數據庫,它總是在單個選項卡上工作,當我更新選項卡或創建新選項卡時,出現問題,推送似乎斷開連接並且我的網格不再更新,奇怪的是我添加了@PreserveOnRefresh,並且在訪問應用程序的第一個選項卡中,即使更新非常奇怪,推送仍然可用。
在我的分貝此實例檢查變化
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(5);
和
我用的是網格更新,與
grid.getDataProvider().refreshAll()
我甚至嘗試播放選項卡,通過圖形的方式在書12.16.4中描述。向其他用戶廣播 ,因爲如果活動通知在所有選項卡中繼續存在,則但網格不存在,僅在原始選項卡中。
更新: 在這個示例應用程序的問題實際上是登錄,當我刪除它,如果一切完美,因爲它應該與推動。但是,只有當我刪除登錄
@Override
public void receiveBroadcast() {
access(() -> {
//Notification.show(message);
//grid.getDataProvider().refreshAll();
getNavigator().removeView(MonitorCrudView.VIEW_NAME);
getNavigator().addView(MonitorCrudView.VIEW_NAME,new MonitorCrudView(this));
getNavigator().navigateTo(MonitorCrudView.VIEW_NAME);
Notification.show("Grid updated", Notification.Type.TRAY_NOTIFICATION);
});
}
的細節是,當我啓用了AccessContro,我作爲管理員的你所看到的輸入,執行上述方法時,我得到類型的異常「沒有請求鏈接到當前線程「;從 「當前用戶」 類 https://github.com/vaadin/archetype-application-example/blob/master/mockapp-ui/src/main/java/org/vaadin/mockapp/samples/authentication/CurrentUser.java
但在這裏vaadin 8.0.4即將變化不大
public final class CurrentUser {
/**
* The attribute key used to store the username in the session.
*/
public static final String CURRENT_USER_SESSION_ATTRIBUTE_KEY = CurrentUser.class
.getCanonicalName();
private CurrentUser() {
}
/**
* Returns the name of the current user stored in the current session, or an
* empty string if no user name is stored.
*
* @throws IllegalStateException
* if the current session cannot be accessed.
*/
public static String get() {
String currentUser = (String) getCurrentRequest().getWrappedSession()
.getAttribute(CURRENT_USER_SESSION_ATTRIBUTE_KEY);
if (currentUser == null) {
return "";
} else {
return currentUser;
}
}
/**
* Sets the name of the current user and stores it in the current session.
* Using a {@code null} username will remove the username from the session.
*
* @throws IllegalStateException
* if the current session cannot be accessed.
*/
public static void set(String currentUser) {
if (currentUser == null) {
getCurrentRequest().getWrappedSession().removeAttribute(
CURRENT_USER_SESSION_ATTRIBUTE_KEY);
} else {
getCurrentRequest().getWrappedSession().setAttribute(
CURRENT_USER_SESSION_ATTRIBUTE_KEY, currentUser);
}
}
private static VaadinRequest getCurrentRequest() {
VaadinRequest request = VaadinService.getCurrentRequest();
if (request == null) {
throw new IllegalStateException(
"No request bound to current thread");
}
return request;
}
}
UPDATE:
在這個類中,我添加了向所有UI廣播的按鈕。
- 以管理員身份登錄
- 單擊更新網格
- 應該給出一個類型的異常
java.util.concurrent.ExecutionException: 的java.lang。IllegalStateException異常:無請求勢必當前線程
不會繼續刷新UI 但在隱身標籤頁打開時,它總是在更新前拋出異常後一次扔exeption。
隨着基礎項目和蒙戈分貝加上
私有靜態ScheduledExecutorService的調度= Executors.newScheduledThreadPool(5);
我總是從上面得到相同的異常,從不與推更改視圖
任何機會,你可以分享[sscce](http:// sscce。org)在github或類似的(忘記數據庫只是使用一些靜態數據),以及一系列步驟來重現您的問題? – Morfic
非常感謝,非常感謝,我試圖在沒有mongodb的情況下重現錯誤,在應用程序本身的例子8.0.4中,但我仍然沒有實現它。 @Morfic –
你好@Morfic你在某種程度上是hahahaha,我不知道是不是問得太多了,但你能看到example github中的代碼嗎? –