Java 类com.vaadin.ui.UIDetachedException 实例源码

项目:chipster    文件:AsynchronousView.java   
/**
 * Thread safe UI updates
 * 
 * Execute UI changes in a runnable after attaining the applications's lock.
 * Runnable won't be run, if the view isn't anymore active. 
 * 
 * Make sure this method won't get called before the UI is ready. In 
 * practice the easiest way to ensure this is to start data queries only 
 * after the UI is initialized and visible.
 * 
 * @param runnable
 */
public void updateUI(Runnable runnable) {

    try {
        ui.access(runnable);

        // this is needed, because the ChipsterAdminUI is configured
        // for manual push
        ui.accessSynchronously(new Runnable() {
            public void run() {
                ui.push();          
            }
        });
    } catch (UIDetachedException e) {
        // user reloaded the page during the update
    }       
}
项目:esup-ecandidat    文件:MainUI.java   
/**
 * Configure la gestion des erreurs
 */
private void configError(){
    /* Log les erreurs non gerees */
    VaadinSession.getCurrent().setErrorHandler(e -> {
        Throwable cause = e.getThrowable();
        while (cause instanceof Throwable) {
            /* Gère les accès non autorisés */
            if (cause instanceof AccessDeniedException) {
                navigateToView(ErreurView.NAME);
                return;
            }
            /* Gère les UIs détachées pour les utilisateurs déconnectés */
            if (cause instanceof AuthenticationCredentialsNotFoundException || cause instanceof UIDetachedException 
                || cause instanceof UploadException || cause instanceof IllegalStateException
                || cause instanceof SocketTimeoutException
                || MethodUtils.checkCause(cause,"SocketTimeoutException")
                || MethodUtils.checkCause(cause,"ClientAbortException")                 
                || cause instanceof EOFException
                || cause instanceof URISyntaxException
                || cause instanceof UIException) {
                sendError();
                cause.printStackTrace();
                return;
            }
            if (MethodUtils.checkCauseByStackTrace(cause,"FileUploadHandler", 0)
                ||
                MethodUtils.checkCauseByStackTrace(cause,"OnDemandPdfBrowserOpener", 1)
                ||
                MethodUtils.checkCauseByStackTrace(cause,"DownloadStream", 3)
                ||
                MethodUtils.checkCauseByStackTrace(cause,"AtmosphereRequest", 7)
                ||
                MethodUtils.checkCauseByStackTrace(cause,"AbstractTextField", 0)
                ||
                MethodUtils.checkCauseByStackTrace(cause,"SocketChannelImpl", 4)
                || 
                MethodUtils.checkCauseEmpty(cause)
                ){
                    sendError();
                    cause.printStackTrace();
                    return;
            }               
            cause = cause.getCause();
        }
        sendError();
        logger.error("Erreur inconnue", e.getThrowable());
    });
}