本文整理汇总了Java中com.vaadin.server.DefaultErrorHandler类的典型用法代码示例。如果您正苦于以下问题:Java DefaultErrorHandler类的具体用法?Java DefaultErrorHandler怎么用?Java DefaultErrorHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultErrorHandler类属于com.vaadin.server包,在下文中一共展示了DefaultErrorHandler类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: error
import com.vaadin.server.DefaultErrorHandler; //导入依赖的package包/类
@Override
public final void error(final ErrorEvent event)
{
//
// Extract the relevant exception
Throwable t = event.getThrowable();
if (t instanceof SocketException)
{
// Most likely client browser closed socket
logger.info("SocketException in CommunicationManager. Most likely client (browser) closed socket.");
return;
}
t = DefaultErrorHandler.findRelevantThrowable(t);
//
// Create error message
final ErrorMessage errorMessage = createErrorMessage(t);
//
// Display it
displayError(errorMessage, event);
// also print the error on console
logger.error("", t);
}
示例2: handle
import com.vaadin.server.DefaultErrorHandler; //导入依赖的package包/类
@Override
public boolean handle(ErrorEvent event, App app) {
boolean handled = super.handle(event, app);
//noinspection ThrowableResultOfMethodCallIgnored
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();
}
//noinspection ThrowableResultOfMethodCallIgnored
if (event.getThrowable() instanceof Validator.InvalidValueException) {
app.getAppUI().discardAccumulatedEvents();
}
}
return handled;
}
示例3: init
import com.vaadin.server.DefaultErrorHandler; //导入依赖的package包/类
@Override
protected void init(VaadinRequest request) {
getPage().setTitle("Vaadin Managed Security Demo");
// Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
setErrorHandler(new DefaultErrorHandler() {
@Override
public void error(com.vaadin.server.ErrorEvent event) {
if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
Notification.show("Sorry, you don't have access to do that.");
} else {
super.error(event);
}
}
});
if (vaadinSecurity.isAuthenticated()) {
showMainScreen();
} else {
showLoginScreen(request.getParameter("goodbye") != null);
}
}
示例4: init
import com.vaadin.server.DefaultErrorHandler; //导入依赖的package包/类
@Override
protected void init(VaadinRequest request) {
getPage().setTitle("Vaadin Shared Security Demo");
// Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
setErrorHandler(new DefaultErrorHandler() {
@Override
public void error(com.vaadin.server.ErrorEvent event) {
if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
Notification.show("Sorry, you don't have access to do that.");
} else {
super.error(event);
}
}
});
HorizontalLayout layout = new HorizontalLayout();
layout.setSizeFull();
// By adding a security item filter, only views that are accessible to the user will show up in the side bar.
sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
layout.addComponent(sideBar);
CssLayout viewContainer = new CssLayout();
viewContainer.setSizeFull();
layout.addComponent(viewContainer);
layout.setExpandRatio(viewContainer, 1f);
Navigator navigator = new Navigator(this, viewContainer);
// Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all.
springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
navigator.addProvider(springViewProvider);
navigator.setErrorView(ErrorView.class);
navigator.navigateTo(navigator.getState());
setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI.
}
示例5: ErrorWindow
import com.vaadin.server.DefaultErrorHandler; //导入依赖的package包/类
public ErrorWindow()
{
// Configure the error handler for the UI
UI.getCurrent().setErrorHandler(new DefaultErrorHandler()
{
private static final long serialVersionUID = 1L;
@Override
public void error(com.vaadin.server.ErrorEvent event)
{
new ErrorWindow(true).internalShowErrorWindow(event.getThrowable());
}
});
}
示例6: init
import com.vaadin.server.DefaultErrorHandler; //导入依赖的package包/类
@Override
protected void init(VaadinRequest request) {
getUI().setLocale(BBPlay.getLanguage(request.getLocale().getLanguage()));
I18n.init(i18n);
getPage().setTitle("BBPlay");
setErrorHandler(new DefaultErrorHandler() {
private static final long serialVersionUID = -18984634551415736L;
@Override
public void error(com.vaadin.server.ErrorEvent event) {
if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
BBPlay.error(I18n.t("error.noAccess", "MainUI"));
} else {
super.error(event);
}
}
});
VerticalLayout layout = new VerticalLayout();
layout.setSizeFull();
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setSizeFull();
layout.addComponent(horizontalLayout);
layout.setExpandRatio(horizontalLayout, 1f);
sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
horizontalLayout.addComponent(sideBar);
CssLayout viewContainer = new CssLayout();
viewContainer.setSizeFull();
viewContainer.addStyleName("scrollable-y");
horizontalLayout.addComponent(viewContainer);
horizontalLayout.setExpandRatio(viewContainer, 1f);
Navigator navigator = new Navigator(this, viewContainer);
springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
navigator.addProvider(springViewProvider);
navigator.setErrorView(NavigatorErrorView.class);
Footer footer = new Footer();
layout.addComponent(footer);
layout.addComponent(animator = new AnimatorProxy());
setContent(layout);
}
示例7: init
import com.vaadin.server.DefaultErrorHandler; //导入依赖的package包/类
@Override
protected void init(VaadinRequest request) {
setLocale(Locale.ENGLISH);
// Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
setErrorHandler(new DefaultErrorHandler() {
@Override
public void error(com.vaadin.server.ErrorEvent event) {
if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
Notification.show("Sorry, you don't have access to do that.");
} else {
super.error(event);
}
}
});
VerticalLayout layout = new VerticalLayout();
Panel viewContent = new Panel();
MenuBar menu = new MenuBar();
menu.addStyleName("navigation-menu");
layout.addComponents(menu, viewContent);
layout.setSizeFull();
viewContent.setSizeFull();
layout.setExpandRatio(viewContent, 1);
menu.addItem("Trading Area", e -> onDashboardClicked());
menu.addItem("Users", e -> onCustomersClicked());
navigator = new Navigator(this, viewContent);
springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
navigator.addProvider(springViewProvider);
navigator.setErrorView(ErrorView.class);
setContent(layout);
String state = navigator.getState();
if(state != null && !state.isEmpty()) {
navigator.navigateTo(state);
}
else {
navigator.navigateTo(TradingAreaView.NAME);
}
}