Package net.sourceforge.stripes.validation

Examples of net.sourceforge.stripes.validation.ValidationErrors


     * them in an instance variable to use during error rendering.
     */
    protected void loadErrors() throws StripesJspException {
        ActionBean actionBean = getActionBean();
        if (actionBean != null) {
            ValidationErrors validationErrors = actionBean.getContext().getValidationErrors();

            if (validationErrors != null) {
                this.fieldErrors = validationErrors.get(getName());
            }
        }
    }
View Full Code Here


            trip.addParameter("two", "not25chars");
            trip.addParameter("three", "3");
            trip.addParameter("four", "onetwothree");
            trip.execute("/Validate.action");

            ValidationErrors errors = trip.getValidationErrors();
            Assert.assertNull(errors.get("one"), "Field one should not have errors.");
            Assert.assertEquals(errors.get("two").size(), 1, "Field two should not have 1 error.");
            Assert.assertEquals(errors.get("three").size(), 1, "Field three should not have errors.");
            Assert.assertEquals(errors.get("four").size(), 1, "Field one should not have errors.");
        } finally {
            ctx.close();
        }
    }
View Full Code Here

          / 24;
      if (days > 365)
        throw new BusinessRuleException(
            "An academic year cannot be more than 365 days");
    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
          "/admin/academicyear/tooLong"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try {
      if (days < 279)
        throw new BusinessRuleException(
            "An academic year cannot be less than 279 days");

    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
          "/admin/academicyear/tooShort"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
View Full Code Here

          / 24;
      if (days > 365)
        throw new BusinessRuleException(
            "An academic year cannot be more than 365 days");
    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
          "/admin/academicyear/tooLong"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try {
      if (days < 279)
        throw new BusinessRuleException(
            "An academic year cannot be less than 279 days");

    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
          "/admin/academicyear/tooShort"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
View Full Code Here

  public Resolution createExam() {
   
    //Check if all dates of exam fall in range of start and end date.
    for(IndividualExam iexam : this.individualExams){
      if(EsimsUtils.compareDates(this.startDate, iexam.getDateOfExam())>0){
        ValidationErrors errors = new ValidationErrors();
        errors.add("individualExams", new LocalizableError(
            "/admin/exam/InvalidDateOfExam"));
        getContext().setValidationErrors(errors);
       
        return getContext().getSourcePageResolution();
      }
      if(EsimsUtils.compareDates(this.endDate, iexam.getDateOfExam())<0){
        ValidationErrors errors = new ValidationErrors();
        errors.add("individualExams", new LocalizableError(
            "/admin/exam/InvalidDateOfExam"));
        getContext().setValidationErrors(errors);
        return getContext().getSourcePageResolution();
      }
    }
View Full Code Here

    this.getContext().setAttributeToSession("buttonName", buttonName);
    this.getContext().setAttributeToSession("buttonValue", buttonValue);
    // If the service layer returns 0 standards it means that we need to
    // warn the user.
    if (listOfStandards.size() == 0) {
      ValidationErrors errors = new ValidationErrors();
      errors
      .add(
          "standardId",
          new LocalizableError(
          "/admin/division/DivisionMgmt.action.standardId.valueNotPresent"));
      this.getContext().setValidationErrors(errors);
View Full Code Here

    try{
      if(EsimsUtils.compareDates(new Date(), this.formIssuedOn)== -1)
        throw new BusinessRuleException("The date of issuing the form cannot be in the future");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formIssuedOn", new LocalizableError("/officestaff/applicationforms/futureFormIssuedDate"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try{
      if(EsimsUtils.compareDates(new Date(), this.formReceivedOn)== -1)
        throw new BusinessRuleException("The date of receiving the form cannot be in the future");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formReceivedOn", new LocalizableError("/officestaff/applicationforms/futureFormReceivedDate"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try{
      if(EsimsUtils.compareDates(this.formFilledOn, this.formIssuedOn)== -1)
        throw new BusinessRuleException("The date of filling the form cannot be earlier than the issual date");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formReceivedOn", new LocalizableError("/officestaff/applicationforms/previousFormFillingDate"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try{
      if(EsimsUtils.compareDates(this.formIssuedOn, this.formReceivedOn)> 0)
        throw new BusinessRuleException("The date of receving the form cannot be earlier than issuance");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formReceivedOn", new LocalizableError("/officestaff/applicationforms/earlierFormReceivedDate"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
   
    String buttonName = "showParentDetailsPage";
View Full Code Here

    int currentYear = today.get(Calendar.YEAR);
    Calendar applicantBirthCal = Calendar.getInstance();
    applicantBirthCal.setTime(applicantDateOfBirth);
    int applicantBirthYear = applicantBirthCal.get(Calendar.YEAR);
    if(currentYear-applicantBirthYear < 5){
      ValidationErrors errors = new ValidationErrors();
      errors.add("applicantDateOfBirth", new LocalizableError("/office/issuedApplicationForm/LowAge"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }

    IssuedApplicationForm issuedApplicationForm = new IssuedApplicationForm(
View Full Code Here

TOP

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

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.