incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r452940 - in /incubator/xap/trunk: WebContent/examples/dataBinding/ src/xap/data/bridge/ src/xap/data/datasource/
Date Wed, 04 Oct 2006 17:11:55 GMT
Author: mturyn
Date: Wed Oct  4 10:11:54 2006
New Revision: 452940

URL: http://svn.apache.org/viewvc?view=rev&rev=452940
Log:
Cleaned up code, tried to make difference between the "source" (the base object used as a
data source) and additional script source brought in via na optional URI.

Modified:
    incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js
    incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html
    incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal
    incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
    incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js
    incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js
    incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js

Modified: incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js?view=diff&rev=452940&r1=452939&r2=452940
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js Wed Oct  4 10:11:54 2006
@@ -52,7 +52,8 @@
 }
 
 
-					
+// for JSON's sake:
+new Employees() ;					
 							
 
 

Modified: incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html?view=diff&rev=452940&r1=452939&r2=452940
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html Wed Oct
 4 10:11:54 2006
@@ -39,7 +39,7 @@
 							"xap.data.bridge.JavascriptDataSourceBridge",							
 							"xap.data.bridge.ObjectDataSourceBridge",
 							"xap.data.controller.ContextFrame",		
-							//"xap.data.controller.Iterator",
+							"xap.data.controller.Iterator",
 							"xap.data.datasource.AbstractDataSet",
 							"xap.data.datasource.AbstractDataSource",							
 							"xap.data.datasource.ArrayDataSet",
@@ -52,7 +52,8 @@
 							"xap.session.DeclarativeArgumentParser",
 							"xap.taghandling.AbstractTagImpl",							
 							"xap.taghandling.AttributeConverter",
-							"xap.xml.dom.Document"																							
+							"xap.xml.dom.Document",
+							"xap.Xap"																							
 							) ;
 		Xap._loadDebuggables() ;
 							

Modified: incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal?view=diff&rev=452940&r1=452939&r2=452940
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal Wed Oct 
4 10:11:54 2006
@@ -5,7 +5,7 @@
 		xmlns="http://www.openxal.org/data"
 		id="myDataSource"
 		source="new Employees()"
-		uri="Employees.js"
+		path="Employees.js"
 	/>	
 	
 	

Modified: incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js?view=diff&rev=452940&r1=452939&r2=452940
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js Wed Oct  4 10:11:54 2006
@@ -54,6 +54,7 @@
 };
 Xap.setupClassAsSubclassOf("xap.data.bridge.DataSourceBridge", "xap.data.bridge.DataFrameworkBridge");
 xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE = "source";
+xap.data.bridge.DataSourceBridge.PATH_ATTRIBUTE = "path";
 xap.data.bridge.DataSourceBridge.NULL_SOURCE_MSGID = "nullSourceObject";
 xap.data.bridge.DataSourceBridge.ID_IS_NOT_SPECIFIED_MSGID = "idNotSpecified";
 
@@ -76,7 +77,7 @@
 /**
  * Implementation of the DataChangeListener interface,
  * fires the "onDataChanged" XML event.
- * @param source{DataSourceImpl}
+ * @param source{AbstractDataSource}
  */
 xap.data.bridge.DataSourceBridge.prototype.onDataChanged = function (source) {
 	this.fireEvent( "onDataChanged", null, null, null) 

Modified: incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js?view=diff&rev=452940&r1=452939&r2=452940
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js Wed Oct  4 10:11:54
2006
@@ -19,7 +19,7 @@
 //import java.net.MalformedURLException;
 Xap.provide("xap.data.bridge.JavascriptDataSourceBridge");
 //superclass:
-Xap.require("xap.data.datasource.AbstractDataSource") ;
+Xap.require("xap.data.bridge.DataSourceBridge") ;
 
 Xap.require("xap.session.EventHandler") ;
 // Xap.require("xap.mco.McoInvocationException") ;
@@ -71,15 +71,11 @@
 //protected DataSource
 xap.data.bridge.JavascriptDataSourceBridge.prototype.createDataSource = function () {
 	/*String*/
-    var uri = this.getElement().getAttribute( "uri" ) ;
+    var uri = this.getElement().getAttribute( xap.data.bridge.DataSourceBridge.PATH_ATTRIBUTE
) ;
 	/*DataSource*/
 	var dataSource = null;
 	try {
-		if( uri ){
-			dataSource = new xap.data.datasource.JavascriptDataSource(this,uri);		
-		} else {
-			dataSource = new xap.data.datasource.JavascriptDataSource(this);				
-		}
+		dataSource = new xap.data.datasource.JavascriptDataSource(this,uri);		
 	}
 	catch (e) { //AttributeConversionException
 //		this.reportInvalidXmlException( xap.data.XmlDataTokens.CLASS, className,
@@ -112,8 +108,19 @@
 		var dataSource = this.getDataSource();
 		/*String*/
 		var sourceString = dataSourceElement.getAttribute(xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE);
-		// Might not do this for this class: this.setRefreshOnPropertyChange(dataSource);
+		this.setRefreshOnPropertyChange(dataSource);
 		this.setSource(dataSource, sourceString);
+		
+		// Path to the script defining the object source references
+		// ---e.g. "source='theArray'" will only be resoluble in
+		// the context of the code from this path, or objects previously
+		// brought into scope some other way---the second possibility's
+		// existence makes this attribute optional:
+		var pathString = dataSourceElement.getAttribute(xap.data.bridge.DataSourceBridge.PATH_ATTRIBUTE);
+		if( pathString && pathString != null && pathString.length>0){
+			this.setRefreshOnPropertyChange(dataSource);
+			this.setPath(dataSource, pathString) ;
+		}
 	}
 	catch (e) {
 			// TODO: Decide what sort of exception 
@@ -141,9 +148,8 @@
  * @private
  * @param dataSource{ObjectDataSource}
  */
-/*  My guess is we won't need this for now (just ONE_TIME/ONE_WAY, but...
 xap.data.bridge.JavascriptDataSourceBridge.prototype.setRefreshOnPropertyChange = function
(dataSource) {
-	var refreshOnPropertyChange = this.getElement().getAttribute(REFRESH_ON_PROPERTY_CHANGE_ATTRIBUTE);
+	var refreshOnPropertyChange = this.getElement().getAttribute(xap.data.bridge.JavascriptDataSourceBridge.REFRESH_ON_PROPERTY_CHANGE_ATTRIBUTE);
 	if (refreshOnPropertyChange != null) {
 		refreshOnPropertyChange = refreshOnPropertyChange.trim().toLowerCase();
 		if (refreshOnPropertyChange.equals("true")) {
@@ -157,7 +163,7 @@
 		}
 	}
 };
-*/
+
 /**
  * @private
  * @param dataSource{ObjectDataSource}
@@ -167,10 +173,6 @@
 xap.data.bridge.JavascriptDataSourceBridge.prototype.setSource = function (dataSource, sourceString)
{
 	/*EventHandler*/
 	this.eventHandler = this.getSession().getEventHandler();
-	// If we needed to prepend with javascript: first, as we may well do 
-	// for ObjectDataSourceBridge, we'd add the following to the
-	// next condition:
-	//&& (sourceString.match(xap.data.datasource.JavascriptDataSource.JS_SOURCE_SIGNATURE)
!= null)	
 	if (sourceString != null 
 		&& sourceString.trim().length != 0 
 			) {
@@ -180,6 +182,29 @@
 	//var lock = this.getElement().getOwnerDocument().getDomSynchronizationObject();
 	//synchronized( lock ) {
 	this.getElement().setAttribute(xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE, sourceString);
+	//}
+};
+
+
+
+/**
+ * @private
+ * @param dataSource{ObjectDataSource}
+ * @param sourceString{String}
+ * @throws MalformedURLException, McoException, EscapeSyntaxException  
+**/
+xap.data.bridge.JavascriptDataSourceBridge.prototype.setPath = function (dataSource, pathString)
{
+	/*EventHandler*/
+	this.eventHandler = this.getSession().getEventHandler();
+	if (pathString != null 
+		&& pathString.trim().length != 0 
+			) {
+		dataSource.setPath(pathString);
+	}
+	/*Object */
+	//var lock = this.getElement().getOwnerDocument().getDomSynchronizationObject();
+	//synchronized( lock ) {
+	this.getElement().setAttribute(xap.data.bridge.DataSourceBridge.PATH_ATTRIBUTE, pathString);
 	//}
 };
 

Modified: incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js?view=diff&rev=452940&r1=452939&r2=452940
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js Wed Oct  4 10:11:54
2006
@@ -580,6 +580,22 @@
 xap.data.datasource.AbstractDataSource.prototype.setSource = function (sourceObject) {
 	this._source = sourceObject;
 };
+
+
+/**
+ * Sets the path urifor this DataSource
+ * 
+ * @param sourceObject The new source object
+ * @protected
+ * @param pathString{String}
+ * @return {void}
+ **/
+xap.data.datasource.AbstractDataSource.prototype.setPath = function (pathString) {
+	this._path = pathString ;
+};
+
+
+
 /**
  * Adds a postponed query to this DataSource. This method can be used to
  * cache queries for later execution (for example if the source object is
@@ -597,11 +613,12 @@
  * @param context{ContextFrame}
  * @param listener{RetrievalListener  }
  **/
-xap.data.datasource.AbstractDataSource.prototype.addPostponedQuery = function (query, context,
listener) {
-	/*QueryRecord*/
-	var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
-	this._postponedQueries.addElement(queryRecord);
-};
+// Not doing this in this release:
+//xap.data.datasource.AbstractDataSource.prototype.addPostponedQuery = function (query, context,
listener) {
+//	/*QueryRecord*/
+//	var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
+//	this._postponedQueries.addElement(queryRecord);
+//};
 /**
  * Executes all posponed queries in order they came in.
  * At the end of this method the postponed query vector is cleared 
@@ -610,42 +627,42 @@
  * @protected
  * @synchronized
  **/
-xap.data.datasource.AbstractDataSource.prototype.executePostponedQueries = function () {
-	try {
-		for (var i = 0; i < this._postponedQueries.size(); i++) {
-			/*QueryRecord*/
-			var rec = this._postponedQueries.elementAt(i);
-			try {
-				this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
-			}
-			catch (e) { // DataAccessException,MalformedQueryException
-				this.getLog().exception(e);
-			}
-		}
-	}
-	finally {
-		this._postponedQueries.removeAllElements();
-	}
-};
+//xap.data.datasource.AbstractDataSource.prototype.executePostponedQueries = function ()
{
+//	try {
+//		for (var i = 0; i < this._postponedQueries.size(); i++) {
+//			/*QueryRecord*/
+//			var rec = this._postponedQueries.elementAt(i);
+//			try {
+//				this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
+//			}
+//			catch (e) { // DataAccessException,MalformedQueryException
+//				this.getLog().exception(e);
+//			}
+//		}
+//	}
+//	finally {
+//		this._postponedQueries.removeAllElements();
+//	}
+//};
 /**
  * Clears the posponed query vector. 
  *
  * @protected
  * @return {void}
  **/
-xap.data.datasource.AbstractDataSource.prototype.clearPostponedQueries = function () {
-	this._postponedQueries.removeAllElements();
-};
-/**
- * @return vector of postponed queries whose execution has been postponed 
- * for some reason (i.e. the source object was not available).
- *
- * @protected
- * @return {Vector}
- **/
-xap.data.datasource.AbstractDataSource.prototype.getPostponedQueries = function () {
-	return this._postponedQueries;
-};
+//xap.data.datasource.AbstractDataSource.prototype.clearPostponedQueries = function () {
+//	this._postponedQueries.removeAllElements();
+//};
+///**
+// * @return vector of postponed queries whose execution has been postponed 
+// * for some reason (i.e. the source object was not available).
+// *
+// * @protected
+// * @return {Vector}
+// **/
+//xap.data.datasource.AbstractDataSource.prototype.getPostponedQueries = function () {
+//	return this._postponedQueries;
+//};
 /**
  * @return vector of all bound queries (bound type != ONE_TIME)
  *
@@ -777,5 +794,21 @@
 		var rec = this._boundQueries.elementAt(i);
 		this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
 	}
+};
+
+/**
+ * Sets the _refreshOnPropertyChange to the newValue. If set to true,
+ * the datasource will be refreshed every time the source object fires
+ * property change events (granted the object contains methods for adding
+ * and removing PropertyChangeListener instances)
+ * 
+ * @param newValue - the new value for the setting
+ *
+ * @public
+ * @param newValue{boolean}
+ * @return {void}
+**/
+xap.data.datasource.AbstractDataSource.prototype.setRefreshOnPropertyChange = function (newValue)
{
+	this._refreshOnPropertyChange = newValue;
 };
 

Modified: incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js?view=diff&rev=452940&r1=452939&r2=452940
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js Wed Oct  4 10:11:54
2006
@@ -1,3 +1,4 @@
+
 /*
  * Copyright  2006 The Apache Software Foundation.
  *
@@ -15,31 +16,15 @@
  *
 **/
 Xap.provide("xap.data.datasource.JavascriptDataSource");
-Xap.require("xap.util.Vector");
-Xap.require("xap.data.events.GenericPropertyChangeListener") ;
-Xap.require("xap.data.datasource.AbstractDataSet") ;
-
-
-xap.data.datasource.JavascriptDataSource = function (handler,uri) {
+Xap.require("xap.util.Vector");
+Xap.require("xap.data.events.GenericPropertyChangeListener");
+Xap.require("xap.data.datasource.AbstractDataSet");
+xap.data.datasource.JavascriptDataSource = function (handler) {
 	//TODO: ? Most of what might be here seems to be in
-	// "initialize"
-	this._uri = uri ;
-	this._handler = handler ;
+	// "initialize"
+	this._handler = handler;
 };
 Xap.setupClassAsSubclassOf("xap.data.datasource.JavascriptDataSource", "xap.data.datasource.AbstractDataSource");
-xap.data.datasource.JavascriptDataSource.JS_SOURCE_SIGNATURE = /^javascript:/;
-/**
- * Removes the prepended "javascript:" from the source, if
- * necessary.  Would be nice if we could test for
- * syntactic validity here, but how?
- * TODO: any other escapes?
- * @param aString{String} the JS string to be eval'd when
- *	getting data:
-**/
-xap.data.datasource.JavascriptDataSource.setSource = function (aString) {
-	var stripped = aString.replace(xap.data.datasource.JavascriptDataSource.JS_SOURCE_SIGNATURE,
"");
-	this.superclass.setSource.call(this, stripped);
-};
 /**
  * @see DataSource#initialize(String, ClientSession, Element)
  *
@@ -52,42 +37,39 @@
 **/
 xap.data.datasource.JavascriptDataSource.prototype.initialize = function (id, session, dataSourceElement)
{
 	xap.data.datasource.AbstractDataSource.prototype.initialize.call(this, id, session, dataSourceElement);
-	this._propertyChangeListener = new xap.data.events.GenericPropertyChangeListener(this);
-	
-	if( this._uri ){
-		this.loadSource(this._uri) ;
-	}
-	
-};
-
+	this._propertyChangeListener = new xap.data.events.GenericPropertyChangeListener(this);
+};
+
+
+
 /**
  * Get the object source from a specified location:
-**/ 
-xap.data.datasource.JavascriptDataSource.prototype.loadSource = function(){
-	var sourceString = null ;
-	try {
-		sourceString = this._handler.getSession().getRequestService().retrieve( this._uri ).responseText;
-	} catch (eU){
-		throw new xap.util.Exception(
-						"Problem getting data from location "
-						+ this._uri
-						+";\n"+eU
-										) ;
-	}
-		
-	try {
-		eval(sourceString) ;
-	} catch (eO){
-		throw new xap.util.Exception(
-						"Problem evaluating:"+eO+" \n"
-						+ sourceString
-										) ;
-	}
-	
-}
-
-
-
+**/
+xap.data.datasource.JavascriptDataSource.prototype.loadScriptFromPath = function () {
+	if( !this._path 
+			|| typeof this._path != "string"
+				|| this._path.length==0
+		){
+		// Might not want to load anything this way---
+		// might have brought in necessary JS objects 
+		// in (e.g.) an HTML script tag:
+		return ;	
+	}
+
+	var sourceString = null;
+	try {
+		sourceString = this._handler.getSession().getRequestService().retrieve(this._path).responseText;
+	}
+	catch (eU) {
+		throw new xap.util.Exception("Problem getting data from location " + this._uri + ";\n"
+ eU);
+	}
+	try {
+		eval(sourceString);
+	}
+	catch (eO) {
+		throw new xap.util.Exception("Problem evaluating:" + eO + " \n" + sourceString);
+	}
+};
 /**
  * @see AbstractDataSource#handleDataQuery( String, Context, 
  *										  DataRetrievalListener )
@@ -98,58 +80,44 @@
  * @param listener{DataRetrievalListener}
  * @throws DataAccessException, MalformedQueryException   
  * @return {void}
-**/
-xap.data.datasource.JavascriptDataSource.prototype.handleDataQuery = function (query, context,
listener) {
-	var contextObjectString = this.getSource();
-	var contextObject = contextObjectString ;
-// Objects we can use when evalling, maybe:
-	var currentIndex = null ;
-	var currentCount = null ;
-	var totalCount = null ;	
-	if (context != null) {
-		contextObjectString = context.getData();		
-		currentIndex = context.getIndex() ;
-		currentCount = currentIndex + 1;
-		totalCount = context.getDataSet().size() ;
-	}
-	if (contextObjectString == null) {
-		this.addPostponedQuery(query, context, listener);
-	} else {
-		try {
-			contextObject = eval(contextObjectString) ;
-		} catch(ex){
-			throw new xap.util.Exception(
-					"JavascriptDataSource.handleDataQuery::source: '"
-											+ theObject
-											+ theScript
-											+"'\n"
-											+anException
-											) ;					
-		}
-	
-	
-		/*Object*/
-		var theData = null ;
-// TODO:  do this right instead.  For the moment, all array
-// return values are treated as part of an iteration:
-		//var theScript = contextObject+"."+query ;
-		var theScript = this.constructor.resolveIteratorMacros(query) ; 	
-		try {			
-			theData = eval(theScript) ;
-		} catch (anException){
-			throw new xap.util.Exception(
-					"JavascriptDataSource.handleDataQuery::source and query: '"
-											+ theScript
-											+"'\n"
-											+anException
-											) ;
-		}
-			
-		listener.dataRetrieved(query, theData, context);
-	}
-};
+**/
+xap.data.datasource.JavascriptDataSource.prototype.handleDataQuery = function (query, context,
listener) {
+	// Get any objects defined in the file
+	// indicated by this._path:
+	this.loadScriptFromPath() ;	
+	var contextObjectString = this.getSource();
+	var contextObject = contextObjectString;
+// Objects we can use when evalling, maybe:
+	var currentIndex = null;
+	var currentCount = null;
+	var totalCount = null;
+	if (context != null) {
+		contextObjectString = context.getData();
+		currentIndex = context.getIndex();
+		currentCount = currentIndex + 1;
+		totalCount = context.getDataSet().size();
+	}
+	try {
+		contextObject = eval(contextObjectString);
+	}
+	catch (ex) {
+		throw new xap.util.Exception("JavascriptDataSource.handleDataQuery::source: '" + theObject
+ theScript + "'\n" + anException);
+	}
+	/*Object*/
+	var theData = null;
+	// TODO:  do this right instead.  For the moment, all array
+	// return values are treated as part of an iteration:
+	//var theScript = contextObject+"."+query ;
+	var theScript = this.constructor.resolveIteratorMacros(query);
+	try {
+		theData = eval(theScript);
+	}
+	catch (anException) {
+		throw new xap.util.Exception("JavascriptDataSource.handleDataQuery::source and query: '"
+ theScript + "'\n" + anException);
+	}
+	listener.dataRetrieved(query, theData, context);
 
-
+};
 /**
  * @see AbstractDataSource#handleDataSetQuery( String, Context, 	 *											 DataSetRetrievalListener
)
  *
@@ -160,49 +128,42 @@
  * @param context{Context}
  * @param listener{DataSetRetrievalListener  }
  * @throws DataAccessException, MalformedQueryException  
-**/
-xap.data.datasource.JavascriptDataSource.prototype.handleDataSetQuery = function (query,
context, listener) {
-	/*Object*/
-	var contextObject = this.getSource();
-	if (context != null) {
-		contextObject = context.getData();
-	}
-	if (contextObject == null) {
-		this.addPostponedQuery(query, context, listener);
-	} else {
-		/*Object*/
-		var theData = null
-		var theScript = contextObject+"."+query ;
-		try {			
-			theData = eval(theScript) ;
-		} catch (anException){
-			throw new xap.util.Exception(
-			"JavascriptDataSource.handleDataSetQuery:Could not evaluate: '"
-											+ theScript
-											+"'"
-											) ;
-		}
-		/*DataSet*/
-		var dataset 
-			= xap.data.datasource.AbstractDataSet.getDataSet(query, this, theData);		
-		listener.dataSetRetrieved(query, dataset, context);
-	}
-};
-
+**/
+xap.data.datasource.JavascriptDataSource.prototype.handleDataSetQuery = function (query,
context, listener) {
+	// Get any objects defined in the file
+	// indicated by this._path:
+	this.loadScriptFromPath() ;
+	/*Object*/
+	var contextObject = this.getSource();
+	if (context != null) {
+		contextObject = context.getData();
+	}
+	/*Object*/
+	var theData = null;
+	var theScript = contextObject + "." + query;
+	try {
+		theData = eval(theScript);
+	}
+	catch (anException) {
+		throw new xap.util.Exception("JavascriptDataSource.handleDataSetQuery:Could not evaluate:
'" + theScript + "'");
+	}
+	/*DataSet*/
+	var dataset = xap.data.datasource.AbstractDataSet.getDataSet(query, this, theData);
+	listener.dataSetRetrieved(query, dataset, context);
+};
 /**
  * A very simple expression language
  * @see handleDataQuery
-**/ 
-xap.data.datasource.JavascriptDataSource.resolveIteratorMacros = function(str ){
-		var result = null ;
-		result = str.replace(/<currentElement>/g,"contextObject") ;
-		result = result.replace(/<currentIndex>/g,"currentIndex") ;		
-		result = result.replace(/<currentCount>/g,"currentCount") ;		
-		result = result.replace(/<totalCount>/g,"totalCount") ;	
-		
-		return result ;
-}
-
-
-
+**/
+xap.data.datasource.JavascriptDataSource.resolveIteratorMacros = function (str) {
+	var result = null;
+	result = str.replace(/<currentElement>/g, "contextObject");
+	result = result.replace(/<currentIndex>/g, "currentIndex");
+	result = result.replace(/<currentCount>/g, "currentCount");
+	result = result.replace(/<totalCount>/g, "totalCount");
+	return result;
+};
+
+
+
 



Mime
View raw message