Package net.sourceforge.stripes.validation

Examples of net.sourceforge.stripes.validation.ScopedLocalizableError


        // Firstly if the post is a multipart request, check to see if a file was
        // sent under that parameter name
        FileBean file = null;
        if (req.isMultipart() && (file = req.getFileParameterValue(name)) != null) {
            if (file.getSize() <= 0) {
                errors.add(name, new ScopedLocalizableError("validation.required",
                        "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.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

                return null;
            }
            return LocaleUtils.toLocale(input);
        }
        catch (IllegalArgumentException e) {
            errors.add(new ScopedLocalizableError("converter.locale", "invalidLocale"));
            return null;
        }
    }
View Full Code Here

    public Resolution ajaxGetIcon() {
        try {
            this.iconUrl = cardService.findFavIconUrl(UrlUtils.absolutizeUrl(this.url));
            if (this.iconUrl == null) {
                getContext().getValidationErrors().addGlobalError(
                    new ScopedLocalizableError(AbstractEditCardActionBean.class.getName(),
                                               "noIconFound"));
            }
        }
        catch (FavIconException e) {
            getContext().getValidationErrors().addGlobalError(
                new ScopedLocalizableError(AbstractEditCardActionBean.class.getName(),
                                           "errorWhileFetchingIcon"));
        }
        return new ForwardResolution("/cards/_icon.jsp");
    }
View Full Code Here

     * @param errors the errors to update
     */
    @ValidationMethod(on = {"modifyCard", "ajaxModifyCard"}, when = ValidationState.ALWAYS)
    public void validatePassword(ValidationErrors errors) {
        if (changePassword && password == null) {
            errors.add("password", new ScopedLocalizableError("validation.required", "valueNotPresent"));
        }
    }
View Full Code Here

        // Firstly if the post is a multipart request, check to see if a file was
        // sent under that parameter name
        FileBean file = null;
        if (req.isMultipart() && (file = req.getFileParameterValue(name)) != null) {
            if (file.getSize() <= 0) {
                errors.add(name, new ScopedLocalizableError("validation.required",
                        "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.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

            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

TOP

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

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.