Package net.sourceforge.stripes.validation

Examples of net.sourceforge.stripes.validation.ValidationError


            if (expression != null) {
                try {
                    ctx.setCurrentValue(value);
                    Boolean result = (Boolean) expression.getValue(ctx);
                    if (!Boolean.TRUE.equals(result)) {
                        ValidationError error = new ScopedLocalizableError(ERROR_DEFAULT_SCOPE, ERROR_KEY);
                        error.setFieldValue(String.valueOf(value));
                        errors.add(name.getName(), error);
                    }
                }
                catch (ELException ele) {
                    log.error("Error evaluating expression for property ", name.getName(),
View Full Code Here


            if (expr != null) {
                try {
                    resolver.setCurrentValue(value);
                    Boolean result = (Boolean) expr.evaluate(resolver);
                    if (!Boolean.TRUE.equals(result)) {
                        ValidationError error = new ScopedLocalizableError(ERROR_DEFAULT_SCOPE,
                                                                           ERROR_KEY);
                        error.setFieldValue(String.valueOf(value));
                        errors.add(name.getName(), error);
                    }
                }
                catch (ELException ele) {
                    log.error("Error evaluating expression for property ", name.getName(),
View Full Code Here

    public Resolution login() {
        PersonManager pm = new PersonManager();
        Person person = pm.getPerson(this.username);

        if (person == null) {
            ValidationError error = new LocalizableError("usernameDoesNotExist");
            getContext().getValidationErrors().add("username", error);
            return getContext().getSourcePageResolution();
        }
        else if (!person.getPassword().equals(password)) {
            ValidationError error = new LocalizableError("incorrectPassword");
            getContext().getValidationErrors().add("password", error);
            return getContext().getSourcePageResolution();
        }
        else {
            getContext().setUser(person);
View Full Code Here

        ErrorsTag parentErrorsTag = getParentTag(ErrorsTag.class);
        if (parentErrorsTag != null) {
            // Mode: sub-tag inside an errors tag
            try {
                ValidationError error = parentErrorsTag.getCurrentError();
                writer.write( error.getMessage(locale) );
            }
            catch (IOException ioe) {
                JspException jspe = new JspException("IOException encountered while writing " +
                    "error tag to the JspWriter.", ioe);
                log.warn(jspe);
View Full Code Here

            if (expression != null) {
                try {
                    ctx.setCurrentValue(value);
                    Boolean result = (Boolean) expression.getValue(ctx);
                    if (!Boolean.TRUE.equals(result)) {
                        ValidationError error = new ScopedLocalizableError(ERROR_DEFAULT_SCOPE, ERROR_KEY);
                        error.setFieldValue(String.valueOf(value));
                        errors.add(name.getName(), error);
                    }
                }
                catch (ELException ele) {
                    log.error("Error evaluating expression for property ", name.getName(),
View Full Code Here

            if (expr != null) {
                try {
                    resolver.setCurrentValue(value);
                    Boolean result = (Boolean) expr.evaluate(resolver);
                    if (!Boolean.TRUE.equals(result)) {
                        ValidationError error = new ScopedLocalizableError(ERROR_DEFAULT_SCOPE,
                                                                           ERROR_KEY);
                        error.setFieldValue(String.valueOf(value));
                        errors.add(name.getName(), error);
                    }
                }
                catch (ELException ele) {
                    log.error("Error evaluating expression for property ", name.getName(),
View Full Code Here

                        "valueNotPresent"));
            }
        }
        // And if not, see if any regular parameters were sent
        else if (values == null || values.length == 0) {
            ValidationError error = new ScopedLocalizableError("validation.required",
                    "valueNotPresent");
            error.setFieldValue(null);
            errors.add(name, error);
        }
        else {
            for (String value : values) {
                if (value == null || value.length() == 0) {
                    ValidationError error = new ScopedLocalizableError("validation.required",
                            "valueNotPresent");
                    error.setFieldValue(value);
                    errors.add(name, error);
                }
            }
        }
    }
View Full Code Here

        for (String value : values) {
            // Only run validations when there are non-empty values
            if (value != null && value.length() > 0) {
                if (validationInfo.minlength() != null
                        && value.length() < validationInfo.minlength()) {
                    ValidationError error = new ScopedLocalizableError("validation.minlength",
                            "valueTooShort", validationInfo.minlength());

                    error.setFieldValue(value);
                    errors.add(error);
                }

                if (validationInfo.maxlength() != null
                        && value.length() > validationInfo.maxlength()) {
                    ValidationError error = new ScopedLocalizableError("validation.maxlength",
                            "valueTooLong", validationInfo.maxlength());
                    error.setFieldValue(value);
                    errors.add(error);
                }

                if (validationInfo.mask() != null
                        && !validationInfo.mask().matcher(value).matches()) {

                    ValidationError error = new ScopedLocalizableError("validation.mask",
                            "valueDoesNotMatch");

                    error.setFieldValue(value);
                    errors.add(error);
                }
            }
        }
    }
View Full Code Here

                if (value instanceof Number) {
                    Number number = (Number) value;

                    if (validationInfo.minvalue() != null
                            && number.doubleValue() < validationInfo.minvalue()) {
                        ValidationError error = new ScopedLocalizableError("validation.minvalue",
                                "valueBelowMinimum", validationInfo.minvalue());
                        error.setFieldValue(String.valueOf(value));
                        errors.add(name.getName(), error);
                    }

                    if (validationInfo.maxvalue() != null
                            && number.doubleValue() > validationInfo.maxvalue()) {
                        ValidationError error = new ScopedLocalizableError("validation.maxvalue",
                                "valueAboveMaximum", validationInfo.maxvalue());
                        error.setFieldValue(String.valueOf(value));
                        errors.add(name.getName(), error);
                    }
                }
            }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.validation.ValidationError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.