Example usage for com.vaadin.data ValidationResult isError

List of usage examples for com.vaadin.data ValidationResult isError

Introduction

In this page you can find the example usage for com.vaadin.data ValidationResult isError.

Prototype

default boolean isError() 

Source Link

Document

Checks if the result denotes an error.

Usage

From source file:org.jpos.qi.QINavigator.java

License:Open Source License

@Override
public void navigateTo(String navigationState) {
    if (app.getUser().isForcePasswordChange()) {
        super.navigateTo("/users/" + app.getUser().getId() + "/profile/password_change");
        return;/*from  w  w w .  ja v a 2 s  .c  om*/
    }
    if (navigationState == null || "".equals(navigationState)) {
        super.navigateTo("/home");
    } else {
        ValidationResult result = validator.apply(navigationState, app.getValueContext());
        if (!result.isError()) {
            try {
                Matcher m = ROUTE_PATTERN.matcher(navigationState);
                boolean allowed = false;
                if (m.matches()) {
                    String route = m.group(1);
                    allowed = hasAccessToRoute(route);
                }
                if (!allowed) {
                    navigationState = "/home";
                }
                super.navigateTo(navigationState);
                if (app.sidebar() != null) {
                    app.sidebar().markAsSelected(navigationState.substring(1).split("/|,|\\?")[0]);
                }
            } catch (IllegalArgumentException e) {
                QI.getQI().displayNotification(e.getMessage());
                super.navigateTo("/home");
            }
        } else {
            QI.getQI().displayNotification(result.getErrorMessage());
            super.navigateTo("/home");
        }
    }
}