=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 2011-09-29 10:23:26 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 2011-09-29 10:43:51 +0000 @@ -232,6 +232,8 @@ String storedBy = currentUserService.getCurrentUsername(); + boolean needsValidation = false; + dataSet = dataSetService.getDataSet( dataSetId ); if ( storedBy == null ) @@ -261,10 +263,12 @@ value = value.trim(); - if ( dataValue == null ) + if( dataValue == null ) { - if ( value != null && value.length() != 0 ) + if( value != null && value.length() > 0 ) { + needsValidation = true; + dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), null, optionCombo ); dataValueService.addDataValue( dataValue ); @@ -272,11 +276,16 @@ } else { - dataValue.setValue( value ); - dataValue.setTimestamp( new Date() ); - dataValue.setStoredBy( storedBy ); - - dataValueService.updateDataValue( dataValue ); + if( !dataValue.getValue().equals( value ) ) + { + needsValidation = true; + + dataValue.setValue( value ); + dataValue.setTimestamp( new Date() ); + dataValue.setStoredBy( storedBy ); + + dataValueService.updateDataValue( dataValue ); + } } } } @@ -303,9 +312,8 @@ validationErrors = sectionFormUtils.getValidationErrorMap( organisationUnit, dataSet, period ); - if ( (validated == null || !validated) && validationErrors.size() > 0 ) + if ( needsValidation ) { - validated = true; return ERROR; }