Example usage for com.vaadin.data Result error

List of usage examples for com.vaadin.data Result error

Introduction

In this page you can find the example usage for com.vaadin.data Result error.

Prototype

public static <R> Result<R> error(String message) 

Source Link

Document

Returns a failure result wrapping the given error message.

Usage

From source file:com.haulmont.cuba.web.widgets.CubaDateField.java

License:Apache License

@Override
protected Result<LocalDate> handleUnparsableDateString(String dateString) {
    if (Objects.equals(dateString, StringUtils.replaceChars(getState(false).dateMask, "#U", "__"))) {
        return Result.ok(null);
    }//from   w  w  w.j  av  a 2 s  . c om

    return Result.error(getParseErrorMessage());
}

From source file:org.jpos.qi.minigl.AccountConverter.java

License:Open Source License

@Override
public Result<Account> convertToModel(String value, ValueContext valueContext) {
    if (value != null && !value.isEmpty()) {
        try {/*from   w  w  w .  j av a 2s  .co m*/
            Account acct = (Account) DB.exec(db -> {
                GLSession session = new GLSession(db);
                Account res = session.getAccount("jcard", value);
                if (res == null && createNew) {
                    if (createFinal)
                        res = new FinalAccount();
                    else
                        res = new CompositeAccount();
                    res.setCode(value);
                } else if (res == null) {
                    throw new BLException("Invalid Account Code");
                }
                return res;
            });
            return Result.ok(acct);
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }
    if (required)
        return Result.error(QI.getQI().getMessage("errorMessage.req", QI.getQI().getMessage("account")));
    else
        return Result.ok(null);
}