@com.vaadin.flow.router.Route(com.vaadin.flow.uitest.ui.InternalErrorView)

Here are the examples of the java api @com.vaadin.flow.router.Route(com.vaadin.flow.uitest.ui.InternalErrorView) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 Source : InternalErrorView.java
with MIT License
from mcollovati

/**
 * @author Vaadin Ltd
 * @since 1.0.
 */
@Route("com.vaadin.flow.uitest.ui.InternalErrorView")
public clreplaced InternalErrorView extends AbstractDivView {

    public InternalErrorView() {
        Div message = new Div();
        message.setId("message");
        NativeButton updateMessageButton = createButton("Update", "update", event -> message.setText("Updated"));
        NativeButton closeSessionButton = createButton("Close session", "close-session", event -> VaadinSession.getCurrent().close());
        NativeButton enableNotificationButton = createButton("Enable session expired notification", "enable-notification", event -> enableSessionExpiredNotification());
        NativeButton causeExceptionButton = createButton("Cause exception", "cause-exception", event -> showInternalError());
        NativeButton resetSystemMessagesButton = createButton("Reset system messages", "reset-system-messages", event -> resetSystemMessages());
        add(message, updateMessageButton, closeSessionButton, enableNotificationButton, causeExceptionButton, resetSystemMessagesButton);
    }

    private void showInternalError() {
        SystemMessages systemMessages = VaadinService.getCurrent().getSystemMessages(getLocale(), VaadinRequest.getCurrent());
        showCriticalNotification(systemMessages.getInternalErrorCaption(), systemMessages.getInternalErrorMessage(), "", systemMessages.getInternalErrorURL());
    }

    protected void showCriticalNotification(String caption, String message, String details, String url) {
        VaadinService service = VaadinService.getCurrent();
        VaadinResponse response = VaadinService.getCurrentResponse();
        try {
            service.writeUncachedStringResponse(response, JsonConstants.JSON_CONTENT_TYPE, VaadinService.createCriticalNotificationJSON(caption, message, details, url));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void enableSessionExpiredNotification() {
        CustomizedSystemMessages sysMessages = new CustomizedSystemMessages();
        sysMessages.setSessionExpiredNotificationEnabled(true);
        VaadinService.getCurrent().setSystemMessagesProvider(systemMessagesInfo -> sysMessages);
    }

    private void resetSystemMessages() {
        VaadinService.getCurrent().setSystemMessagesProvider(DefaultSystemMessagesProvider.get());
    }
}