Package net.sourceforge.stripes.validation

Examples of net.sourceforge.stripes.validation.ValidationError


                        "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

        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

              }
              TicketNote note = tckt.createNote(getSession(), attachment.getInputStream(), incCapturedCount(), attachment.getFileName());
              if (getCapturedPage1().length()==0) setCapturedPage1(note.id());
              attachment.delete();
            } else {
              ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
              getContext().getValidationErrors().add("items" , error);
            }
          }
          } // next
        disconnect();
View Full Code Here

              if (capturedCount==1) {
                capuredpage1 = page.id();
              }
              attachment.delete();
            } else {
              ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
              getContext().getValidationErrors().add("items" , error);
            }
          }
          } // next
        disconnect();
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.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

    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

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.