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/04 23:30:14 UTC

svn commit: r453063 - in /incubator/xap/trunk: WebContent/examples/dataBinding/ src/xap/data/bridge/ src/xap/data/datasource/ src/xap/taghandling/

Author: mturyn
Date: Wed Oct  4 16:30:12 2006
New Revision: 453063

URL: http://svn.apache.org/viewvc?view=rev&rev=453063
Log: (empty)

Added:
    incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js   (with props)
    incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.html   (with props)
    incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal   (with props)
    incubator/xap/trunk/src/xap/data/bridge/JsonDataSourceBridge.js   (with props)
    incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js
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/JavascriptDataSourceBridge.js
    incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js
    incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js
    incubator/xap/trunk/src/xap/taghandling/plugin.xml

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=453063&r1=453062&r2=453063
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js Wed Oct  4 16:30:12 2006
@@ -32,6 +32,13 @@
 	return ""+(offset+((3+anIndex)*50))+"px" ;
 }
 
+Employees.computeX= function(anIndex, offset){
+	if(!offset){
+		offset = 0 ;
+	}
+	return ""+(offset+((anIndex%3)*50))+"px" ;
+}
+
 Employees.prototype.second = function(){
 	return "The second slot in this array will give us: "
 			+Employees.array[1]+"." ;
@@ -51,10 +58,22 @@
 	return vec ;
 }
 
+// Mission creep:
+
+// For a fan-fold effect:
+Employees._colors = ["#e0ffe0","#ffffd8"] ;
+			
+Employees._colorIndex = 1 ;
+
+Employees.thisColor = function(){
+	return Employees._colors[Employees._colorIndex] ;
+}
 
-// for JSON's sake:
-new Employees() ;					
-							
+Employees.nextColor = function(){
+	Employees._colorIndex += 1 ;
+	Employees._colorIndex = Employees._colorIndex%(Employees._colors.length) ;
+	return Employees.thisColor() ;
+}							
 
 
 

Added: incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js?view=auto&rev=453063
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js Wed Oct  4 16:30:12 2006
@@ -0,0 +1,14 @@
+var employees = {
+	"array":[
+			{"lname":"Last name", "fname":"First name", "id":"i.d."},
+			{"lname":"Doe", "fname":"John", "id":"001"},
+			{"lname":"Roe", "fname":"Mary", "id":"002"},
+			{"lname":"Smith", "fname":"Winston", "id":"003"},
+			{"lname":"O'Brien", "fname":"Julia", "id":"004"},
+			{"lname":"Venture", "fname":"Thaddeus", "id":"005"},
+			{"lname":"Savage", "fname":"Danforth \"Doc\"", "id":"006"},
+			{"lname":"Brown", "fname":"Jordan", "id":"007"},
+			{"lname":"Puneval", "fname":"Theophilus", "id":"008"}
+		]
+}
+

Propchange: incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js
------------------------------------------------------------------------------
    svn:eol-style = native

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=453063&r1=453062&r2=453063
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html Wed Oct  4 16:30:12 2006
@@ -17,7 +17,8 @@
 	</script>
 
 		<script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
-		<!--  No longer need this---now grabs JS source using source object's 'uri' attribute: -->
+		<script language="JavaScript" type="text/javascript" src="Layout.js"></script>		
+		<!--  No longer need this---now grabs JS source using source object's 'path' attribute: -->
 		<!--  script language="JavaScript" type="text/javascript" src="Employees.js"></script -->
 
 <!--  

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=453063&r1=453062&r2=453063
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal Wed Oct  4 16:30:12 2006
@@ -16,6 +16,13 @@
 		id="SECOND"
 	/>	
 
+	<!-- For colors: -->
+	<mco:mco 
+		xmlns:mco="http://www.openxal.org/mco" 
+		src="Layout"
+		id="layout" 
+	/>
+
 
 	<xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
 	<xm:append select="/xal">
@@ -67,16 +74,16 @@
 					xmlns="http://www.openxal.org/data" 
 					name="anIterator" 
 					dataSource="myDataSource" 
-					select="theArray()" 
+					select="<currentElement>.theArray()" 
 					type="ONE_WAY"
 				>
 
 					<xal:label 
 						y="{*('Employees.computeY(<currentIndex>)')}"
-						x="25px"			
-						width="290px" 			
+						x="20px"			
+						width="292px" 			
 						height="40px"				
-						backgroundColor="#ddddff" 
+						backgroundColor="{mco:layout.nextColour()}"
 						alignHorizontal="center" 
 						text="{*('&quot;Iteration &quot;+<currentCount>+&quot; of   &quot;+<totalCount>+&quot;.&quot;')}"
 					/>
@@ -84,20 +91,20 @@
 
 					<xal:label 
 						y="{*('Employees.computeY(<currentIndex>)')}"
-						x="330px"			
-						width="290px" 			
+						x="318px"		
+						width="288px" 			
 						height="40px"				
-						backgroundColor="#ffdddd" 
+						backgroundColor="{mco:layout.thisColour()}"
 						alignHorizontal="center" 
 						text="{*('<currentElement>.id')}"
 					/>
 					
 					<xal:label 
 						y="{*('Employees.computeY(<currentIndex>)')}"
-						x="655px"			
+						x="612px"			
 						width="290px" 			
 						height="40px"				
-						backgroundColor="#ddffdd" 
+						backgroundColor="{mco:layout.thisColour()}" 
 						alignHorizontal="left" 
 						text="{*('&quot;. . . &quot;+<currentElement>.lname+&quot;, &quot;+<currentElement>.fname')}"
 					/>					

Added: incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.html?view=auto&rev=453063
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.html (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.html Wed Oct  4 16:30:12 2006
@@ -0,0 +1,68 @@
+<html>
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+		<title>Getting data from a JSON-compliant data source:</title>
+
+		<style type="text/css">
+      <!--
+          @import url(../../css/xapDefault.css);
+      -->
+    </style>
+
+		<!-- Keep dojo from trying to scan this whole page for dojoType'd tags: -->
+		<script type="text/javascript">
+		djConfig = {
+			parseWidgets: false
+		};
+	</script>
+
+		<script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
+		<!--  No longer need this---now grabs JS source using source object's 'uri' attribute: -->
+		<!--  script language="JavaScript" type="text/javascript" src="Employees.js"></script -->
+
+<!--  
+Remove debugging in a final check, since debugging's 
+alternate loading method (using <script/> tags) can
+mask forgetting a .require(<className>) in the code:
+-->
+
+    <script language="JavaScript" type="text/javascript">
+
+    	Xap._sourceRootDir = "../../" ; 
+    		Xap.addDebuggables(		
+							"xap.data.DataFramework",
+							"xap.data.DataServiceFactory",
+							"xap.data.DataServiceImpl",
+							"xap.data.bridge.DataAttributeConverter",
+							"xap.data.bridge.DataFrameworkBridge",
+							"xap.data.bridge.DataSourceBridge",
+							"xap.data.bridge.JsonDataSourceBridge",							
+							"xap.data.bridge.ObjectDataSourceBridge",
+							"xap.data.controller.ContextFrame",		
+							"xap.data.controller.Iterator",
+							"xap.data.datasource.AbstractDataSet",
+							"xap.data.datasource.AbstractDataSource",							
+							"xap.data.datasource.ArrayDataSet",
+							"xap.data.datasource.DataSetFactory",						
+							"xap.data.datasource.DataSourceContainerImpl",
+							"xap.data.datasource.DataSourceImpl",
+							"xap.data.datasource.JsonDataSource",
+							"xap.data.datasource.JavascriptDataSource",							
+							"xap.resolver.AttributeResolutionHandler",
+							"xap.session.ClientSession",
+							"xap.session.DeclarativeArgumentParser",
+							"xap.taghandling.AbstractTagImpl",							
+							"xap.taghandling.AttributeConverter",
+							"xap.xml.dom.Document",
+							"xap.Xap"																							
+							) ;	
+		Xap._loadDebuggables() ;
+							
+	</script>							
+
+	</head>
+
+	<body onload="Xap.createAllPredefinedSessions();">
+		<div style="left:100px;top:100px" xapId="JsonExample" xapSrc="jsonDatasource.xal" xapToolkit="dojo" xapContext="../../"></div>
+	</body>
+</html>

Propchange: incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal?view=auto&rev=453063
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal Wed Oct  4 16:30:12 2006
@@ -0,0 +1,61 @@
+<xal xmlns="http://www.openxal.org/xal" xmlns:xal="http://www.openxal.org/xal"> 
+
+	<!-- 
+		loads file at the path, which at top-level
+		should contain a variable named by "source"'s
+		value:
+	-->
+	<jsonDataSource
+		xmlns="http://www.openxal.org/data"
+		id="myDataSource"
+		path="Employees_json.js"
+		source="employees"
+	/>	
+	
+	
+	<xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
+	<xm:append select="/xal">
+
+		<xal:table id="testComponent" width="600px">
+			<xal:column>
+				<xal:header text="i.d." />
+			</xal:column>
+			<xal:column>
+				<xal:header text="" />
+			</xal:column>								
+			<xal:column>
+				<xal:header text="last name" />
+			</xal:column>
+			<xal:column>
+				<xal:header text="first name" />
+			</xal:column>
+	
+		
+<!-- Iterator -->
+			<iterator 
+				xmlns="http://www.openxal.org/data" 
+				name="anIterator" 
+				dataSource="myDataSource" 
+				select="array" 
+				type="ONE_WAY"
+			>
+
+				<xal:row>
+				<!--  
+					Each of these should be an Employee.Record
+					instance, which will admit the following 
+					method:
+				-->
+					<xal:cell text="{*('id')}"/>
+					<xal:cell text=""/>				
+					<xal:cell text="{*('fname')}"/>				
+					<xal:cell text="{*('lname')}"/>
+
+				</xal:row>	
+						
+			</iterator>
+		</xal:table>
+				
+	</xm:append> 	  		
+  	</xm:modifications>
+</xal>

Propchange: incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal
------------------------------------------------------------------------------
    svn:eol-style = native

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=453063&r1=453062&r2=453063
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js Wed Oct  4 16:30:12 2006
@@ -67,15 +67,24 @@
 //-----------------------------------------------------------------------
 // Protected Methods.
 //-----------------------------------------------------------------------
+
+
+/**
+ * Returns a new data source...only difference (so far) between this
+ * class and its JSON-restricted subclass:
+**/
+xap.data.bridge.JavascriptDataSourceBridge.prototype.createNewDataSource = function(){
+	return new xap.data.datasource.JavascriptDataSource(this,false);
+} 
+
+
 	
 //protected DataSource
 xap.data.bridge.JavascriptDataSourceBridge.prototype.createDataSource = function () {
-	/*String*/
-    var uri = this.getElement().getAttribute( xap.data.bridge.DataSourceBridge.PATH_ATTRIBUTE ) ;
 	/*DataSource*/
 	var dataSource = null;
 	try {
-		dataSource = new xap.data.datasource.JavascriptDataSource(this,uri);		
+		dataSource = this.createNewDataSource() ;		
 	}
 	catch (e) { //AttributeConversionException
 //		this.reportInvalidXmlException( xap.data.XmlDataTokens.CLASS, className,

Added: incubator/xap/trunk/src/xap/data/bridge/JsonDataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/JsonDataSourceBridge.js?view=auto&rev=453063
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/JsonDataSourceBridge.js (added)
+++ incubator/xap/trunk/src/xap/data/bridge/JsonDataSourceBridge.js Wed Oct  4 16:30:12 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright  2006 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *	  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+ 
+//import java.net.MalformedURLException;
+Xap.provide("xap.data.bridge.JsonDataSourceBridge");
+//superclass:
+Xap.require("xap.data.bridge.JavascriptDataSourceBridge") ;
+
+Xap.require("xap.session.EventHandler") ;
+// Xap.require("xap.mco.McoInvocationException") ;
+Xap.require("xap.taghandling.AttributeConversionException");
+//Xap.require("xap.plugin.data.InitializationException") ;
+Xap.require("xap.data.datasource.JsonDataSource") ;
+Xap.require("xap.data.datasource.AbstractDataSource") ;
+Xap.require("xap.data.datasource.JsonDataSource") ;
+//Xap.require("xap.util.EscapeSyntaxException") ;
+// /Xap.require("xap.util.ResourceDictionary") ; 
+Xap.require("xap.xml.dom.XapElement");
+Xap.require("xap.data.bridge.DataSourceBridge");
+Xap.require("xap.data.XmlDataTokens") ;
+
+
+
+/**
+ * JsonDataSourceBridge is a bridge class for the javascriptDataSource tag,
+ * stolen liberally from ObjectDataSourceBridge as ported.
+ *
+ * @author ikaplansky
+ * @author mturyn 
+ */
+xap.data.bridge.JsonDataSourceBridge = function(){
+	xap.data.bridge.JavascriptDataSourceBridge.call(this);
+};
+
+Xap.setupClassAsSubclassOf("xap.data.bridge.JsonDataSourceBridge", "xap.data.bridge.JavascriptDataSourceBridge");
+
+/**
+ * Returns a new data source...only difference (so far) between this
+ * class and its superclass:
+**/
+xap.data.bridge.JsonDataSourceBridge.prototype.createNewDataSource = function(){
+	return new xap.data.datasource.JsonDataSource(this,true);
+} 
+

Propchange: incubator/xap/trunk/src/xap/data/bridge/JsonDataSourceBridge.js
------------------------------------------------------------------------------
    svn:eol-style = native

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=453063&r1=453062&r2=453063
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js Wed Oct  4 16:30:12 2006
@@ -1,4 +1,3 @@
-
 /*
  * Copyright  2006 The Apache Software Foundation.
  *
@@ -23,7 +22,8 @@
 	//TODO: ? Most of what might be here seems to be in
 	// "initialize"
 	this._handler = handler;
-};
+};
+
 Xap.setupClassAsSubclassOf("xap.data.datasource.JavascriptDataSource", "xap.data.datasource.AbstractDataSource");
 /**
  * @see DataSource#initialize(String, ClientSession, Element)
@@ -39,36 +39,27 @@
 	xap.data.datasource.AbstractDataSource.prototype.initialize.call(this, id, session, dataSourceElement);
 	this._propertyChangeListener = new xap.data.events.GenericPropertyChangeListener(this);
 };
-
-
-
 /**
- * Get the object source from a specified location:
+ * Get the object source from a specified location, make it a local
+ * variable of the calling function.
 **/
-xap.data.datasource.JavascriptDataSource.prototype.loadScriptFromPath = function () {
-	if( !this._path 
-			|| typeof this._path != "string"
-				|| this._path.length==0
-		){
+xap.data.datasource.JavascriptDataSource.prototype.getScriptFromPath = 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 
+		// might have brought in necessary JS objects
 		// in (e.g.) an HTML script tag:
-		return ;	
+		return;
 	}
-
 	var sourceString = null;
+	var result = 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);
-	}
+	
+	return sourceString ;
 };
 /**
  * @see AbstractDataSource#handleDataQuery( String, Context, 
@@ -81,27 +72,40 @@
  * @throws DataAccessException, MalformedQueryException   
  * @return {void}
 **/
-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:
+xap.data.datasource.JavascriptDataSource.prototype.handleDataQuery = function (query, context, listener) {
+	var sourceString = this.getScriptFromPath() ; 
+	try {
+		eval(sourceString);
+	}
+	catch (eO) {
+		throw new xap.util.Exception("Problem evaluating:" + eO + " \n" + sourceString);
+	}
+	var contextObject = null;
+	// The source object is created by evaluating the
+	// source script---note that we needed to load
+	// the script pointed-to by the "path"
+	// attribute, because it might contain context necessary
+	// to evaluate the following, or the query:
+	contextObject = eval( this.getSource() );
+
+
+// Objects we can use when evalling an iterator:
 	var currentIndex = null;
 	var currentCount = null;
 	var totalCount = null;
 	if (context != null) {
+	// We're getting context from an iterator
+	// context-frame stack:
 		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);
+		try {
+			contextObject = eval(contextObjectString);
+		}
+		catch (ex) {
+			throw new xap.util.Exception("JavascriptDataSource.handleDataQuery::source: '" + theObject + theScript + "'\n" + anException);
+		}
 	}
 	/*Object*/
 	var theData = null;
@@ -109,6 +113,11 @@
 	// return values are treated as part of an iteration:
 	//var theScript = contextObject+"."+query ;
 	var theScript = this.constructor.resolveIteratorMacros(query);
+	// This basic JS data source evaluates the query as-is, not
+	// considering it as an operator on the source object.
+	// Note, though, that the source object is still there, the result
+	// of eval(element.source), and aliased as <currentElement>
+	// for use in this scriptlet:
 	try {
 		theData = eval(theScript);
 	}
@@ -116,7 +125,6 @@
 		throw new xap.util.Exception("JavascriptDataSource.handleDataQuery::source and query: '" + theScript + "'\n" + anException);
 	}
 	listener.dataRetrieved(query, theData, context);
-
 };
 /**
  * @see AbstractDataSource#handleDataSetQuery( String, Context, 	 *											 DataSetRetrievalListener )
@@ -127,20 +135,36 @@
  * @param query{String}
  * @param context{Context}
  * @param listener{DataSetRetrievalListener  }
- * @throws DataAccessException, MalformedQueryException  
+ * @throws DataAccessException, MalformedQueryException
+ * @see handleDataQuery  
 **/
 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();
+	var sourceString = this.getScriptFromPath() ; 
+	try {
+		eval(sourceString);
+	}
+	catch (eO) {
+		throw new xap.util.Exception("Problem evaluating:" + eO + " \n" + sourceString);
+	}
+	// The source object is created by evaluating the
+	// source script---note that we still needed to load
+	// the script pointed-to by the "path"
+	// attribute, because it might contain context necessary
+	// to evaluate the following, or the query:
+	contextObject = eval( this.getSource() );
+	
+	
 	if (context != null) {
 		contextObject = context.getData();
 	}
 	/*Object*/
 	var theData = null;
-	var theScript = contextObject + "." + query;
+	var theScript = this.constructor.resolveIteratorMacros(query);
+	// This basic JS data source evaluates the query as-is, not
+	// considering it as an operator on the source object.
+	// Note, though, that the source object is still there, the result
+	// of eval(element.source), and aliased as <currentElement>
+	// for use in this scriptlet:	
 	try {
 		theData = eval(theScript);
 	}
@@ -163,7 +187,4 @@
 	result = result.replace(/<totalCount>/g, "totalCount");
 	return result;
 };
-
-
-
 

Added: 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=auto&rev=453063
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js (added)
+++ incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js Wed Oct  4 16:30:12 2006
@@ -0,0 +1,148 @@
+
+/*
+ * Copyright  2006 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *	  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+**/
+Xap.provide("xap.data.datasource.JsonDataSource");
+Xap.require("xap.util.Vector");
+Xap.require("xap.data.events.GenericPropertyChangeListener");
+Xap.require("xap.data.datasource.AbstractDataSet");
+xap.data.datasource.JsonDataSource = function (handler) {
+	xap.data.datasource.JavascriptDataSource.call(this, handler);
+};
+Xap.setupClassAsSubclassOf("xap.data.datasource.JsonDataSource", "xap.data.datasource.JavascriptDataSource");
+/**
+ * @see AbstractDataSource#handleDataQuery( String, Context, 
+ *										  DataRetrievalListener )
+ *
+ * @protected
+ * @param query{String}
+ * @param context{Context} 
+ * @param listener{DataRetrievalListener}
+ * @throws DataAccessException, MalformedQueryException   
+ * @return {void}
+**/
+xap.data.datasource.JsonDataSource.prototype.handleDataQuery = function (query, context, listener) {
+
+
+
+// Objects we can use when evalling an iterator:
+	var currentIndex = null;
+	var currentCount = null;
+	var totalCount = null;
+
+	var contextObject = null;
+
+	
+	if (context == null){
+		var sourceString = this.getScriptFromPath(); 
+		// The JSON standard is such that when we evaluate
+		// a file of JSON code, an object will be left on the stack:
+		try {
+			eval(sourceString);
+			contextObject = eval(this.getSource) ;
+		}
+		catch (eO) {
+			throw new xap.util.Exception("Problem evaluating:" + eO + " \n" + sourceString);
+		}				
+	} else {
+	// We're getting context from an iterator
+	// context-frame stack:
+		contextObjectString = context.getData();
+		currentIndex = context.getIndex();
+		currentCount = currentIndex + 1;
+		totalCount = context.getDataSet().size();
+		try {
+			contextObject = eval(contextObjectString);
+		}
+		catch (ex) {
+			throw new xap.util.Exception("JsonDataSource.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);
+	// 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);
+	}
+	listener.dataRetrieved(query, theData, context);
+};
+/**
+ * @see AbstractDataSource#handleDataSetQuery( String, Context, 	 *											 DataSetRetrievalListener )
+ *
+ * @protected
+ * @return {void}
+ *
+ * @param query{String}
+ * @param context{Context}
+ * @param listener{DataSetRetrievalListener  }
+ * @throws DataAccessException, MalformedQueryException  
+**/
+xap.data.datasource.JsonDataSource.prototype.handleDataSetQuery = function (query, context, listener) {
+	var contextObject = null;
+
+	if (context != null) {
+		contextObject = context.getData();
+	}  else {
+		var sourceString = this.getScriptFromPath(); 
+		// Brings in object with the name we expect from "getSource"
+		try {
+			eval(sourceString);
+			contextObject = eval(this.getSource()) ;
+		}
+		catch (eO) {
+			throw new xap.util.Exception("Problem evaluating:" + eO + " \n" + sourceString);
+		}
+	}
+	
+	/*Object*/
+	var theData = null;
+	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 + "'");
+	}
+	/*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.JsonDataSource.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;
+};
+

Modified: incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js?view=diff&rev=453063&r1=453062&r2=453063
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js Wed Oct  4 16:30:12 2006
@@ -198,21 +198,7 @@
 xap.data.datasource.ObjectDataSource.prototype.loadObjectFromUrl = function (sourceUrl) {
 	this.superclass.loadSourceFromServer.call(sourceUrl);
 };
-/**
- * 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.ObjectDataSource.prototype.setRefreshOnPropertyChange = function (newValue) {
-	this._refreshOnPropertyChange = newValue;
-};
+
 /**
  * @return the value of _refreshOnPropertyChange
  * @see #setRefreshOnPropertyChange(boolean)

Modified: incubator/xap/trunk/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/plugin.xml?view=diff&rev=453063&r1=453062&r2=453063
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Wed Oct  4 16:30:12 2006
@@ -10,6 +10,7 @@
 		<mapping class="xap.data.bridge.ObjectDataSourceBridge" name="objectDataSource"/>	
 		<mapping class="xap.data.bridge.JavascriptDataSourceBridge" name="javascriptDataSource"/>	
 		<mapping class="xap.data.bridge.SimpleDocumentDataSourceBridge" name="simpleDocumentDataSource"/>	
+		<mapping class="xap.data.bridge.JsonDataSourceBridge" name="jsonDataSource"/>	
 	</tag-mappings>		
 	
 	<!-- binding -->
@@ -103,4 +104,8 @@
 		<mapping class="xap.bridges.google.GoogleIconsBridge" name="icons"/>
 		<mapping class="xap.bridges.google.GoogleIconBridge" name="icon"/>
 	</tag-mappings>
+	
+
+	
+	
 </plugin>