com.vaadin.server.DefaultErrorHandler Java Examples
The following examples show how to use
com.vaadin.server.DefaultErrorHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InvalidValueExceptionHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override public boolean handle(ErrorEvent event, App app) { boolean handled = super.handle(event, app); if (handled && event.getThrowable() != null) { // Finds the original source of the error/exception AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event); if (component != null) { component.markAsDirty(); } if (component instanceof Component.Focusable) { ((Component.Focusable) component).focus(); } } return handled; }
Example #2
Source File: DesktopApplication.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void init(VaadinRequest request) { broadcastReceiverService = AppContextUtil.getSpringBean(BroadcastReceiverService.class); ServerConfiguration serverConfiguration = AppContextUtil.getSpringBean(ServerConfiguration.class); if (serverConfiguration.isPush()) { getPushConfiguration().setPushMode(PushMode.MANUAL); } UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { private static final long serialVersionUID = 1L; @Override public void error(com.vaadin.server.ErrorEvent event) { Throwable e = event.getThrowable(); handleException(request, e); } }); setCurrentFragmentUrl(this.getPage().getUriFragment()); setCurrentContext(new UserUIContext()); postSetupApp(request); EventBusFactory.getInstance().register(new ShellErrorHandler()); mainWindowContainer = new MainWindowContainer(); this.setContent(mainWindowContainer); getPage().addPopStateListener((Page.PopStateListener) event -> enter(event.getPage().getUriFragment())); String userAgent = request.getHeader("user-agent"); if (isInNotSupportedBrowserList(userAgent.toLowerCase())) { NotificationUtil.showWarningNotification(UserUIContext.getMessage(ErrorI18nEnum.BROWSER_OUT_UP_DATE)); } }
Example #3
Source File: GiftcardUI.java From giftcard-demo with Apache License 2.0 | 4 votes |
@Override protected void init(VaadinRequest vaadinRequest) { HorizontalLayout commandBar = new HorizontalLayout(); commandBar.setWidth("100%"); commandBar.addComponents(issuePanel(), bulkIssuePanel(), redeemPanel()); Grid summary = summaryGrid(); HorizontalLayout statusBar = new HorizontalLayout(); Label statusLabel = new Label("Status"); statusBar.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); statusBar.addComponent(statusLabel); statusBar.setWidth("100%"); VerticalLayout layout = new VerticalLayout(); layout.addComponents(commandBar, summary, statusBar); layout.setExpandRatio(summary, 1f); layout.setSizeFull(); setContent(layout); UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { Throwable cause = event.getThrowable(); log.error("an error occured", cause); while(cause.getCause() != null) cause = cause.getCause(); Notification.show("Error", cause.getMessage(), Notification.Type.ERROR_MESSAGE); } }); setPollInterval(1000); int offset = Page.getCurrent().getWebBrowser().getTimezoneOffset(); // offset is in milliseconds ZoneOffset instantOffset = ZoneOffset.ofTotalSeconds(offset/1000); StatusUpdater statusUpdater = new StatusUpdater(statusLabel, instantOffset); updaterThread = Executors.newScheduledThreadPool(1).scheduleAtFixedRate(statusUpdater, 1000, 5000, TimeUnit.MILLISECONDS); setPollInterval(1000); getSession().getSession().setMaxInactiveInterval(30); addDetachListener((DetachListener) detachEvent -> { log.warn("Closing UI"); updaterThread.cancel(true); }); }