/** * Validates the forth section of study and save it into study bean * * @param request * @param response * @throws Exception */ private void confirmStudy4() throws Exception { FormProcessor fp = new FormProcessor(request); Validator v = new Validator(request); v.addValidation( "conditions", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 500); v.addValidation( "keywords", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255); v.addValidation( "eligibility", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 500); errors = v.validate(); if (fp.getInt("expectedTotalEnrollment") <= 0) { Validator.addError( errors, "expectedTotalEnrollment", respage.getString("expected_total_enrollment_must_be_a_positive_number")); } StudyBean newStudy = (StudyBean) session.getAttribute("newStudy"); newStudy.setConditions(fp.getString("conditions")); newStudy.setKeywords(fp.getString("keywords")); newStudy.setEligibility(fp.getString("eligibility")); newStudy.setGender(fp.getString("gender")); newStudy.setAgeMax(fp.getString("ageMax")); newStudy.setAgeMin(fp.getString("ageMin")); newStudy.setHealthyVolunteerAccepted(fp.getBoolean("healthyVolunteerAccepted")); newStudy.setExpectedTotalEnrollment(fp.getInt("expectedTotalEnrollment")); session.setAttribute("newStudy", newStudy); request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap); if (errors.isEmpty()) { forwardPage(Page.UPDATE_STUDY6); } else { request.setAttribute("formMessages", errors); forwardPage(Page.UPDATE_STUDY5); } }
private void validateStudy4(FormProcessor fp, Validator v) { v.addValidation( "conditions", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 500); v.addValidation( "keywords", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255); v.addValidation( "eligibility", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 500); errors = v.validate(); if (fp.getInt("expectedTotalEnrollment") <= 0) { Validator.addError( errors, "expectedTotalEnrollment", respage.getString("expected_total_enrollment_must_be_a_positive_number")); } study.setConditions(fp.getString("conditions")); study.setKeywords(fp.getString("keywords")); study.setEligibility(fp.getString("eligibility")); study.setGender(fp.getString("gender")); study.setAgeMax(fp.getString("ageMax")); study.setAgeMin(fp.getString("ageMin")); study.setHealthyVolunteerAccepted(fp.getBoolean("healthyVolunteerAccepted")); study.setExpectedTotalEnrollment(fp.getInt("expectedTotalEnrollment")); request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap); }