You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/10/05 06:43:49 UTC

svn commit: r453115 - /incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js

Author: mturyn
Date: Wed Oct  4 23:43:49 2006
New Revision: 453115

URL: http://svn.apache.org/viewvc?view=rev&rev=453115
Log:
Fixed behaviour for empty select statement, which should give the whole object.

Modified:
    incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js

Modified: incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js?view=diff&rev=453115&r1=453114&r2=453115
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js Wed Oct  4 23:43:49 2006
@@ -52,7 +52,7 @@
 		// a file of JSON code, an object will be left on the stack:
 		try {
 			eval(sourceString);
-			contextObject = eval(this.getSource) ;
+			contextObject = eval(this.getSource()) ;
 		}
 		catch (eO) {
 			throw new xap.util.Exception("Problem evaluating:" + eO + " \n" + sourceString);
@@ -80,12 +80,17 @@
 	// Because this is a JSON data source, the
 	// source object is the base of all queries:
 	// 		<src_obj>.a_0()...a_n()
-	theScript = "contextObject." + theScript;
-	try {
-		theData = eval(theScript);
-	}
-	catch (anException) {
-		throw new xap.util.Exception("JsonDataSource.handleDataQuery::source and query: '" + theScript + "'\n" + anException);
+	if( theScript.length>0){
+		theScript = "contextObject." + theScript;
+		try {
+			theData = eval(theScript);
+		}
+		catch (anException) {
+			throw new xap.util.Exception("JsonDataSource.handleDataQuery::source and query: '" + theScript + "'\n" + anException);
+		}
+	} else {
+		//Empty "select"
+		theData = contextObject ;
 	}
 	listener.dataRetrieved(query, theData, context);
 };
@@ -122,12 +127,16 @@
 	var theScript = this.constructor.resolveIteratorMacros(query);
 	// This is a JSON bridge, the source object
 	// is the base of all queries:  <src_obj>.a_0()...a_n()
-	theScript = "contextObject." + theScript;
-	try {
-		theData = eval(theScript);
-	}
-	catch (anException) {
-		throw new xap.util.Exception("JsonDataSource.handleDataSetQuery:Could not evaluate: '" + theScript + "'");
+	if(theScript.length>0){
+		theScript = "contextObject." + theScript;
+		try {
+			theData = eval(theScript);
+		}
+		catch (anException) {
+			throw new xap.util.Exception("JsonDataSource.handleDataSetQuery:Could not evaluate: '" + theScript + "'");
+		}
+	} else {
+		theData = contextObject ;
 	}
 	/*DataSet*/
 	var dataset = xap.data.datasource.AbstractDataSet.getDataSet(query, this, theData);