Skip to content

Commit

Permalink
TRUNK-4261: Error while submitting empty form in the page: "openmrs/a…
Browse files Browse the repository at this point in the history
…dmin/concepts/conceptReferenceTerm.form"

commit 3cb0f3c
Author: Julius Duic <jpduic1@gmail.com>
Date:   Wed Jul 23 15:00:55 2014 -0400

    Display multiple form errors when validating

commit 6037cf3
Author: Marvin Yan <marvin.yan@outlook.com>
Date:   Wed Jul 23 14:06:51 2014 -0400

    Add check for null ConceptSource
  • Loading branch information
marvinyan committed Jul 23, 2014
1 parent 9d5e5bb commit abdfcb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ public void validate(Object obj, Errors errors) throws APIException {
ConceptReferenceTerm conceptReferenceTerm = (ConceptReferenceTerm) obj;

String code = conceptReferenceTerm.getCode();
boolean hasBlankFields = false;
if (!StringUtils.hasText(code)) {
errors.rejectValue("code", "ConceptReferenceTerm.error.codeRequired",
"The code property is required for a concept reference term");
return;
hasBlankFields = true;
}
if (conceptReferenceTerm.getConceptSource() == null) {
errors.rejectValue("conceptSource", "ConceptReferenceTerm.error.sourceRequired",
"The conceptSource property is required for a concept reference term");
hasBlankFields = true;
}
if (hasBlankFields) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.openmrs.ConceptReferenceTerm;
import org.openmrs.ConceptReferenceTermMap;
import org.openmrs.ConceptSource;
import org.openmrs.validator.ConceptReferenceTermValidator;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
Expand All @@ -34,10 +35,10 @@ public boolean supports(Class<?> clazz) {
@Override
public void validate(Object target, Errors errors) {
ConceptReferenceTerm conceptReferenceTerm = (ConceptReferenceTerm) target;
if (conceptReferenceTerm.getConceptSource().getId() == null) {
ConceptSource conceptSource = conceptReferenceTerm.getConceptSource();
if (conceptSource != null && conceptSource.getId() == null) {
errors.rejectValue("conceptSource", "ConceptReferenceTerm.source.notInDatabase",
"Only existing concept reference sources can be used");

}
if (conceptReferenceTerm.getConceptReferenceTermMaps() != null) {
int mapsIndex = 0;
Expand Down

0 comments on commit abdfcb0

Please sign in to comment.