Example usage for com.vaadin.data ValidationResult getErrorMessage

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

Introduction

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

Prototype

String getErrorMessage();

Source Link

Document

Returns the result message.

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;/*  w  w w  .j  av a 2s . 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");
        }
    }
}