=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2012-02-22 17:43:09 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2012-02-22 18:07:04 +0000 @@ -138,9 +138,8 @@ - /dhis-web-validationrule/responseSuccess.vm - /dhis-web-validationrule/responseError.vm - /dhis-web-validationrule/responseInput.vm + /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseInput.vm === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js 2012-01-22 06:34:56 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js 2012-02-22 18:07:04 +0000 @@ -1,7 +1,7 @@ var startDate; var endDate; +var aggregate; var validationRuleGroupId; -var aggregate; var organisationUnitId; function organisationUnitSelected( ids ) @@ -11,49 +11,36 @@ function validateRunValidation() { - var request = new Request(); - request.setResponseTypeXML( 'message' ); - request.setCallbackSuccess( runValidationCompleted ); - - request.send( 'validateRunValidation.action?startDate=' + getFieldValue( 'startDate' ) + '&endDate=' - + getFieldValue( 'endDate' ) + '&aggregate=' + getFieldValue( 'aggregate' ) ); + startDate = $( '#startDate' ).val(); + endDate = $( '#endDate' ).val(); + aggregate = $( '#aggregate' ).val(); + validationRuleGroupId = $( '#validationRuleGroupId' ).val(); + + $.getJSON( 'validateRunValidation.action', + { startDate:startDate, endDate:endDate, aggregate:aggregate }, function( json ) + { + if ( json.response == 'success' ) + { + setWaitMessage( i18n_analysing_please_wait ); + + $.get( 'runValidationAction.action', + { organisationUnitId:organisationUnitId, startDate:startDate, endDate:endDate, validationRuleGroupId:validationRuleGroupId, aggregate:aggregate }, function( data ) + { + $( 'div#analysisInput' ).hide(); + $( 'div#analysisResult' ).show(); + $( 'div#analysisResult' ).html( data ); + pageInit(); + } ); + } + else if ( json.response == 'input' ) + { + setMessage( json.message ); + } + } ); return false; } -function runValidationCompleted( messageElement ) -{ - var type = messageElement.getAttribute( 'type' ); - var message = messageElement.firstChild.nodeValue; - - if ( type == 'success' ) - { - setWaitMessage( "Analysing data, please wait" ); - - startDate = getFieldValue( 'startDate' ); - endDate = getFieldValue( 'endDate' ); - validationRuleGroupId = $( '#validationRuleGroupId' ).val(); - aggregate = $( '#aggregate' ).val(); - - var url = 'runValidationAction.action?organisationUnitId=' + organisationUnitId + '&startDate=' + startDate - + '&endDate=' + endDate + '&validationRuleGroupId=' + validationRuleGroupId + '&aggregate=' + aggregate; - - $.get( url, function( data ) - { - $( "div#analysisInput" ).hide(); - $( "div#analysisResult" ).show(); - $( "div#analysisResult" ).html( data ); - pageInit(); - } ); - } else if ( type == 'error' ) - { - window.alert( i18n_validation_failed + ':' + '\n' + message ); - } else if ( type == 'input' ) - { - setMessage( message ); - } -} - function drillDownValidation( orgUnitId ) { setHeaderWaitMessage( i18n_analysing_please_wait );