dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06310
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1985: Switch to use json instead of xml ajax response to avoid bug in IE8, fix bug #588399.
------------------------------------------------------------
revno: 1985
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Mon 2010-06-14 19:47:51 +0700
message:
Switch to use json instead of xml ajax response to avoid bug in IE8, fix bug #588399.
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/commons.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js
dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/commons.js 2010-06-09 06:37:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/commons.js 2010-06-14 12:47:51 +0000
@@ -772,26 +772,6 @@
setSelectionRange( input, pos, pos );
}
-function getFilteredDataElementsReceived( xmlObject )
-{
- var operandList = document.getElementById( "dataElementId" );
-
- operandList.options.length = 0;
-
- var operands = xmlObject.getElementsByTagName( "operand" );
-
- for ( var i = 0; i < operands.length; i++)
- {
- var id = operands[ i ].getElementsByTagName( "operandId" )[0].firstChild.nodeValue;
- var elementName = operands[ i ].getElementsByTagName( "operandName" )[0].firstChild.nodeValue;
-
- var option = document.createElement( "option" );
- option.value = "[" + id + "]";
- option.text = elementName;
- operandList.add( option, null );
- }
-}
-
function insertTextCommon( inputAreaName, inputText )
{
var inputArea = document.getElementById( inputAreaName );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2010-05-29 16:09:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2010-06-14 12:47:51 +0000
@@ -754,8 +754,8 @@
<action name="getFilteredDataElements"
class="org.hisp.dhis.dd.action.indicatordenum.GetFilteredDataElementsAction">
- <result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlOperands.vm</result>
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonOperands.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js 2010-06-03 17:23:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js 2010-06-14 12:47:51 +0000
@@ -1,4 +1,3 @@
-
function filterDataElements( aggregationOperatorRadioGroupName, dataElementGroupSelectName, filterName )
{
var aggregationOperator = getSelectedRadioValue( aggregationOperatorRadioGroupName );
@@ -6,13 +5,29 @@
var dataElementGroupId = dataElementGroup.options[ dataElementGroup.selectedIndex ].value;
var filter = htmlEncode( document.getElementById( filterName ).value );
- var url = "getFilteredDataElements.action?aggregationOperator=" + aggregationOperator +
- "&dataElementGroupId=" + dataElementGroupId + "&filter=" + filter;
-
- var request = new Request();
- request.setResponseTypeXML( 'operand' );
- request.setCallbackSuccess( getFilteredDataElementsReceived );
- request.send( url );
+ var url = "getFilteredDataElements.action";
+
+ $.getJSON(
+ url,
+ {
+ "aggregationOperator": aggregationOperator,
+ "dataElementGroupId": dataElementGroupId,
+ "filter": filter
+ },
+ function( json )
+ {
+ var operandList = document.getElementById( "dataElementId" );
+ clearList( operandList );
+
+ var objects = json.operands;
+
+ for ( var i=0; i<objects.length; i++ )
+ {
+ addOptionToList( operandList, "[" + objects[i].operandId + "]", objects[i].operandName );
+ }
+
+ }
+ );
}
function getSelectedRadioValue( radioGroupName )
@@ -182,4 +197,4 @@
function updateFormulaTextReceived( messageElement )
{
document.getElementById( "formulaText" ).innerHTML = messageElement;
-}
+}
\ No newline at end of file
=== 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 2010-05-27 17:25:36 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2010-06-14 12:47:51 +0000
@@ -94,7 +94,7 @@
</action>
<action name="getFilteredDataElements" class="org.hisp.dhis.validationrule.action.GetFilteredDataElementsAction">
- <result name="success" type="velocity-xml">/dhis-web-commons/ajax/xmlOperands.vm</result>
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonOperands.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js 2010-06-03 17:23:13 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js 2010-06-14 12:47:51 +0000
@@ -46,14 +46,29 @@
var filter = htmlEncode( byId( filterName ).value );
var periodTypeName = getFieldValue( 'periodTypeName');
- var url = "getFilteredDataElements.action?dataSetId=" + dataSetId;
- url += "&filter=" + filter;
- url += "&periodTypeName=" + periodTypeName;
+ var url = "getFilteredDataElements.action";
+
+ $.getJSON(
+ url,
+ {
+ "dataSetId": dataSetId,
+ "periodTypeName": periodTypeName,
+ "filter": filter
+ },
+ function( json )
+ {
+ var operandList = document.getElementById( "dataElementId" );
+ clearList( operandList );
+
+ var objects = json.operands;
+
+ for ( var i=0; i<objects.length; i++ )
+ {
+ addOptionToList( operandList, "[" + objects[i].operandId + "]", objects[i].operandName );
+ }
- var request = new Request();
- request.setResponseTypeXML( 'operand' );
- request.setCallbackSuccess( getFilteredDataElementsReceived );
- request.send( url );
+ }
+ );
}
function updateTextualExpression( expressionFieldName )