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/01 07:23:50 UTC

svn commit: r451723 [2/3] - in /incubator/xap/trunk: WebContent/examples/dataBinding/ src/xap/data/ src/xap/data/bridge/ src/xap/data/controller/ src/xap/data/datasource/ src/xap/taghandling/ src/xap/xml/

Added: incubator/xap/trunk/src/xap/data/controller/Iterator.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/Iterator.js?view=auto&rev=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/Iterator.js (added)
+++ incubator/xap/trunk/src/xap/data/controller/Iterator.js Sun Oct  1 00:23:49 2006
@@ -0,0 +1,665 @@
+
+/*
+ * 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.controller.Iterator");
+Xap.require("xap.data.controller.IteratorContainerImpl");
+Xap.require("xap.data.controller.ElementLocation");
+Xap.require("xap.session.ClientSession"); 
+//Xap.require("xap.UiUpdateQueue") 
+Xap.require("xap.util.Exception"); 
+//Xap.require("xap.data.DataException") 
+Xap.require("xap.data.DataFramework");
+Xap.require("xap.data.DataServiceImpl");
+Xap.require("xap.data.DataServiceFactory");
+
+//Xap.require("xap.data.datasource.DataSetRetrievalListener") 
+Xap.require("xap.data.datasource.DataSourceImpl");
+Xap.require("xap.xml.dom.XapElement");
+Xap.require("xap.data.controller.BindingResolver");
+Xap.require("xap.data.controller.ContextFrame");
+/**
+ * This class is responsible for managing an occurence of the iterator tag.
+ * All created elements must be tracked, the relative location of the iterator tag's
+ * appearance must be remembered, and the validity of that location must be monitored.
+ * 
+ * @author dgennaco
+ */
+/**
+ * Construct an iterator either with a supplied context ("relative iterator") 
+ * or an implied one (default).
+ * 
+ * @param select{String} the query to be executed against the data source.
+ * 
+ * @param type{xap.data.controller.BindingType} the binding type, ONE_TIME iterators clean up immediately
+ * after a data set is retrieved from the data source, other iterators
+ * continue listening for data source changes so that they can re-iterate.
+ * 
+ * @param iteratorElement{xap.xml.dom.XapElement} the iterator element encountered in the UI dom
+ * 
+ * @param name{String} the name of the iterator - to be used in context lookups
+ * 
+ * @param session{xap.client.ClientSession} the client session
+ * @param ancestorIteratorName{String} the name of the iterator ancestor against
+ * which the query may be made.  The query will be made against this ancestor's
+ * data source with the context of the current iteration index.  If not supplied
+ * iterator will stick to the default context.
+ */
+xap.data.controller.Iterator = function (select, type, iteratorElement, name, session, ancestorIteratorName) {
+    this._select = select;
+    this._bindingType = type;
+    this._iteratorElement = iteratorElement;
+    this._iteratorPlaceHolderElement = iteratorElement.getOwnerDocument().createElement("iteratorPlaceHolder");
+    this._parentElement = iteratorElement.getParent();
+    this._parentLocation = new xap.data.controller.ElementLocation(iteratorElement.getParent());
+    this._parentLocation.setLocationListener(this);
+    this._name = name;
+    this._session = session;
+    /*xap.data.controller.ElementLocation*/
+    var iteratorLocation = new xap.data.controller.ElementLocation(this._iteratorElement);
+    iteratorLocation.setLocationListener(this);
+    this._iteratedLocations = new xap.util.Vector();
+    this._iteratedLocations.addElement(iteratorLocation);
+    /*DataFramework*/
+    var svc = xap.data.DataServiceFactory.getDataService(this._session);
+
+	//get the context stack from the resolver
+    /*BindingResolver*/
+    var resolver = svc.getBindingResolver();
+    /*ContextStack*/
+    var contextStack = resolver.getContextStack();
+    this._contextStack = contextStack.clone();
+    /*ContextFrame*/
+    var context = this._contextStack.getCurrentContext();
+
+	// Register us with our parent iterator (if they created us directly they will hang on to
+	// us for clean up purposes.
+    if (context != null) {
+        /*Iterator*/
+        var parentIterator = svc.getIteratorContainer().getIterator(context.getName(), context.getDataSet());
+        if (parentIterator != null) {
+            parentIterator.registerIteratorLocation(this._iteratorElement, this);
+        }
+        this._context = context;
+    }
+    svc.getIteratorContainer().addIterator(this._name, this);
+
+
+	// If there's an ancestor iterator, make it the parent to this one, else stop here:
+    if (typeof ancestorIteratorName != "undefined") {
+        /*ContextFrame*/
+        var context = this._contextStack.getContext(ancestorIteratorName);
+        if (context == null) {
+//	this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE
+            +"::Iterator(): can't get context corresponding to ancestor named '" + ancestorIteratorName + "'.",
+//					  new DataControllerException(DataControllerException.RELATIVE_ITERATOR_INVALID_PARENT_REFERENCE,
+//								  new String [] { ancestorIteratorName, this._iteratorElement.toString() }));
+// TODO:  Proper exception handling---bring
+// back DataControllerException:
+            this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE + ": no ancestor iterator.", "DataControllerException.RELATIVE_ITERATOR_INVALID_PARENT_REFERENCE", [ancestorIteratorName, "" + this._iteratorElement]);
+            this.invalidate();
+            return;
+        }
+        this._context = context;
+        try {
+            context.getDataSource().getDataSet(this._select, this, context);
+        }
+        catch (e) { //DataException
+            this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE + ": can't get data set from context.", e);
+        }
+    }
+};
+Xap.setupClassAsSubclassOf("xap.data.controller.Iterator", "Object");
+/**
+	* @private
+ * The select string
+ */
+xap.data.controller.Iterator.prototype._select = null;
+/**
+	* @private
+ * The name of this iterator.
+ */
+xap.data.controller.Iterator.prototype._name = null;
+/**
+ * @private
+ * {xap.xml.dom.XapElement}
+ * The <iterator> tag itself
+ */
+xap.data.controller.Iterator.prototype._iteratorElement = null;
+/**
+ * The parent of the <iterator> tag. We really also need to remember
+ * something about the position of the iterator? Maybe we don't replace the
+ * iterator until we do the first iteration, and when we iterate we just
+ * find our own tag, remove it and then start adding the iterated items
+ * in the position we were in. (Similar to include tag)
+ * {xap.xml.dom.XapElement}	 
+ * @private
+ * 
+ */
+xap.data.controller.Iterator.prototype._parentElement = null;
+/**
+ * @private
+ * {xap.data.controller.ElementLocation}
+	**/
+xap.data.controller.Iterator.prototype._parentLocation = null;
+/**
+ * @private
+ * {xap.xml.dom.XapElement}	
+ **/
+xap.data.controller.Iterator.prototype._iteratorPlaceHolderElement = null;
+/**
+ * @
+	private xap.data.controller.BindingType
+**/
+xap.data.controller.Iterator.prototype._bindingType = xap.data.controller.BindingType.ONE_TIME;
+/**
+ * The list of items added by the iterator. When we re-iterate
+ * we need to remove these items then add the new ones in their place.
+ * We may also want to handle if one item of the data set changed
+ * replacing the old iterated node with the new one.
+ *
+ * @private Vector
+**/
+xap.data.controller.Iterator.prototype._iteratedLocations = new Array(0);
+/**
+ * @private 
+ * {xap.session.ClientSession }
+**/
+xap.data.controller.Iterator.prototype._session = null;
+/**
+ * @private
+ * {DataSet}
+ * The current data set we are iterating over
+ */
+xap.data.controller.Iterator.prototype._dataSet = null;
+/**
+* @private
+* {ContextStack}
+**/
+xap.data.controller.Iterator.prototype._contextStack = null;
+/**
+* @private
+* {Object}
+**/
+xap.data.controller.Iterator.prototype._context = null;
+/**
+* Listener on this iterator.
+* @private
+* {LocationListener}
+**/
+xap.data.controller.Iterator.prototype._locationListener; 
+// This needs to be set to true while iterating
+// over a data set so that clean up logic can run without
+/**
+ * @private boolean
+**/
+xap.data.controller.Iterator.prototype._iterating = false;
+/**
+ * Returns the name of this iterator.
+ * 
+ * @return The name.
+ *
+ * @public
+ * @return {String}
+**/
+xap.data.controller.Iterator.prototype.getName = function () {
+    return this._name;
+};
+/**
+ * @private
+ * @return {void}
+ *
+ * @param iteratorElement{Element}
+ * @param location{Location}
+**/
+xap.data.controller.Iterator.prototype.registerIteratorLocation = function (iteratorElement, location) {
+    /*Location*/
+    var iteratorLocation = this.getChildLocation(iteratorElement);
+// If a child iterator is registering and we placed the iterator element
+//	1) replace the iteratedElements location of the element with the location of the iterator
+//	2) listen to the iterator location for invalidation
+//	3) STOP listenening to the iterator element location itself.
+    if (iteratorLocation != null) {
+        /*int*/
+        var index = this._iteratedLocations.indexOf(iteratorLocation);
+        this._iteratedLocations.removeElementAt(index);
+        this._iteratedLocations.insertElementAt(location, index);
+        location.setLocationListener(this);
+        iteratorLocation.setLocationListener(null);
+    }
+};
+/**
+ * @private
+ * @return {Location}
+ *
+ * @param e{Element}
+**/
+xap.data.controller.Iterator.prototype.getChildLocation = function (e) {
+    for (var i = 0; i < this._iteratedLocations.size(); i++) {
+        /*Location*/
+        var l = this._iteratedLocations.elementAt(i);
+        if (l instanceof xap.data.controller.ElementLocation) {
+            if ((l)._element == e) {
+                return l;
+            }
+        }
+    }
+    return null;
+};
+/**
+ * Returns the data set we are/did iterate over.
+ * 
+ * @return the dataset
+ *
+ * @public
+ * @return {DataSet}
+**/
+xap.data.controller.Iterator.prototype.getDataSet = function () {
+    return this._dataSet;
+};
+/**
+ * Iterate over the specified data source.
+ * @private implementor for iterator with explicit source
+ * @param source the data source
+ *
+ * @public
+ * @return {void}
+ *
+ * @param source{DataSource}
+**/
+xap.data.controller.Iterator.prototype._iterateOverSpecifiedSource = function (source) {
+    try {
+        this._context = source;
+        source.getDataSet(this._select, this);
+    }
+    catch (e) { //NexawebException
+        source.removeListener(this);
+        this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE + ": can't get data set from given source.", e);
+    }
+};
+/**
+ * Iterate (or re-iterate).
+ *
+ * @public
+ * @return {void}
+**/
+xap.data.controller.Iterator.prototype.iterate = function () {
+// A bit kludgy, but keeps the two overloaded functionalities
+// separate:
+    if (arguments.length > 0) {
+        this._iterateOverSpecifiedSource.apply(this, arguments);
+        return;
+    }
+    try {
+        /*ContextFrame*/
+        var context = this._contextStack.getCurrentContext();
+        if (context == null) {
+            this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE + "::Iterator.iterate():  relative iterator without a parent context.", new xap.util.Exception("DataControllerException.RELATIVE_ITERATOR_WITHOUT_PARENT" + this._iteratorElement));
+			//						new DataControllerException(DataControllerException.RELATIVE_ITERATOR_WITHOUT_PARENT,
+			//								this._iteratorElement.toString() )
+			// Use a better exception, like this ne, in the above?			
+            this.invalidate();
+            return;
+        }
+        this._context = context;
+        context.getDataSource().getDataSet(this._select, this, context);
+    }
+    catch (e) { //DataException
+        this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE + "::Iterator.iterate(): can't get data set from context.", e);
+    }
+};
+/**
+ * @private
+ * @return {int}
+**/
+xap.data.controller.Iterator.prototype.cleanupCreation = function () {
+//		synchronized (this._session.getDocumentRegistry().getUiDocument().getDomSynchronizationObject()) {
+    /*int*/
+    var iteratorLocationIndex = -1;
+// first remove the old iterated nodes
+    for (var i = this._iteratedLocations.size() - 1; i >= 0; i--) {
+        /*Location*/
+        var location = this._iteratedLocations.elementAt(i);
+        if (i == 0) { // Could be pricey, do this once only (last position)
+            if (location instanceof xap.data.controller.ElementLocation) {
+                iteratorLocationIndex = (location).getIndex();
+            } else {
+                if (location instanceof TextNodeLocation) {
+                    iteratorLocationIndex = (location).getIndex();
+                } else {
+                    if (location instanceof xap.data.controller.Iterator) {
+                        iteratorLocationIndex = (location).cleanupCreation();
+                    }
+                }
+            }
+        }
+        location.remove();
+    }
+    return iteratorLocationIndex;
+//		}
+};
+/**
+ * Reiterate relative to a parent iterator
+ * 
+ * @param dataSet the data set from the parent iterator, used
+ * to retrieve the data source associated with it.
+ *
+ * @public
+ * @return {void}
+ *
+ * @param dataSet{DataSet}
+**/
+xap.data.controller.Iterator.prototype.iterateOverDataSet = function (dataSet) {
+//		synchronized (this._session.getDocumentRegistry().getUiDocument().getDomSynchronizationObject()) {
+    this._context = dataSet.getDataSource();
+    if (this._iteratedLocations.size() == 0) {
+		// All contextual information about the iterator has
+		// been removed prior to a refresh call from a data source,
+		// invalidate and exit.
+        this.invalidate();
+        return;
+    }
+			
+	//Important: this only makes sense to do for UI changes but our data
+	//binding is ONLY ui for now. This will optimize the case where
+	//the bindings being added here resolve instantly and schedule
+	//their UI updates on the UI queue. If the bindings do not resolve
+	//instantly this won't have much effect. Note that the symmetrical
+	//unfreeze is scheduled at the very end of this method.
+   // this._session.getDisplayService().freezeUiUpdates(true);
+    /*BindingResolver*/
+    var resolver = (xap.data.DataServiceFactory.getDataService(this._session)).getBindingResolver();
+    /*ContextStack*/
+    var oldContextStack = resolver.getContextStack();
+    this._iterating = true;
+    try {
+        /*int*/
+        var insertIndex = this.cleanupCreation();
+				
+				//our data set is now the passed in
+        this._dataSet = dataSet;
+        resolver.setContextStack(this._contextStack);
+				
+				//for each item in the data set we take all the child
+				//elements of the <iterator> tag, clone them, and add them
+				//to the <iterator> parent itself. That will then trigger
+				//attribute resolution on each child binding that needs it
+				//as adding the clones will invoke the plug-in handling stuff
+        if (this._dataSet.size() > 0) {
+            for (var currentIndex = 0; currentIndex < this._dataSet.size(); currentIndex++) {
+                this._contextStack.pushContext(new xap.data.controller.ContextFrame(this._dataSet, currentIndex, this._name));
+                try {
+                    for (var childIndex = 0; childIndex < this._iteratorElement.getChildCount(); childIndex++) {
+                        /*Object*/
+                        var child = this._iteratorElement.getChildAt(childIndex);
+                        /*Location*/
+                        var location = null;
+                        if (child instanceof xap.xml.dom.XapElement) {
+                            /*Element*/
+                            var childClone = (child).deepClone(false);
+                            if (this._bindingType != xap.data.controller.BindingType.ONE_TIME) {
+                                location = new xap.data.controller.ElementLocation(childClone);
+                                this._iteratedLocations.addElement(location);
+                            }
+//                          this._parentElement.insertChildAt(insertIndex, childClone);
+							this._parentElement.appendChild(childClone) ;
+                        } else {
+                            if (child instanceof String) {
+                                this._parentElement.insertChildAt(insertIndex, child);
+                                if (this._bindingType != xap.data.controller.BindingType.ONE_TIME) {
+                                    location = new TextNodeLocation(this._parentElement, insertIndex, false);
+                                    this._iteratedLocations.addElement(location);
+                                }
+                            }
+                        }
+                        if (location != null) {
+                            location.setLocationListener(this);
+                        }
+                        insertIndex++;
+                    }
+                }
+                finally {
+							//now that we are done with this iteration, pop the context
+                    this._contextStack.popContext();
+                }
+            }
+        } else {
+					// No data, and we are ONE_TIME, so don't add a placeholder.
+					// if not one time, add placeholder like so:
+            if (this._bindingType != xap.data.controller.BindingType.ONE_TIME) {
+                this._parentElement.insertChildAt(insertIndex, this._iteratorPlaceHolderElement);
+                /*xap.data.controller.ElementLocation*/
+                var location = new xap.data.controller.ElementLocation(this._iteratorPlaceHolderElement);
+                this._iteratedLocations.addElement(location);
+                location.setLocationListener(this);
+                insertIndex++;
+            }
+        }
+        if (this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
+					// ONE_TIME, throw away everything, we are done.
+            this.clearListenersAndIterator();
+        }
+    }
+    catch (e) { //Exception
+        this.invalidate();
+        this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE + "::Iterator.iterateOverDataSet()", new DataControllerException(DataControllerException.ITERATOR_LOOP_EXCEPTION, e));
+    }
+    finally {
+        this._iterating = false;
+				//now that we are done iterating return the state of the global context
+        resolver.setContextStack(oldContextStack);
+        //this._session.getUiUpdateQueue().invokeLater(new this.UiUpdatesUnfreezeTask(this._session));
+    }
+//		}
+};
+/**
+ * Set the binding type for the iterator.  It can be ONE_WAY or 
+ * ONE_TIME.
+ * 
+ * @param bindingType The binding type.
+ *
+ * @public
+ * @return {void}
+ *
+ * @param bindingType{BindingType}
+**/
+xap.data.controller.Iterator.prototype.setBindingType = function (bindingType) {
+    this._bindingType = bindingType;
+};
+/*
+ * DataSetRetrievalListener interface methods.
+ */
+/**
+ * @public
+ * @return {void}
+ *
+ * @param query{String}
+ * @param dataSet{DataSet} 
+ * @param ctx{Context}
+**/
+xap.data.controller.Iterator.prototype.dataSetRetrieved = function (query, dataSet, ctx) {
+    this._dataSet = dataSet;
+    try {
+		// We've got the data, now iterate over them:
+    	this.iterateOverDataSet(dataSet) ;
+    }
+    catch (e) { //Exception
+        this._session.handleException(
+							        	xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE 
+							        	+ ": error iterating over retrieved data set: "
+							        	+ e.getMessage(), 
+							        	e
+        									);
+    }
+};
+/**
+ * @public
+ * @return {BindingType}
+**/
+xap.data.controller.Iterator.prototype.getBindingType = function () {
+    return this._bindingType;
+};
+
+
+
+	
+// Call this method after a data set traversal when ONE_TIME binding type is indicated
+// for this iterator, this will 1) invalidate all XmlLocations (causing them to deregister their
+// xml event listeners, and fire their invalidationListeners, which will, in turn cause this
+// iterator to remove it from its list) and 2) remove this iterator from the iterator container
+// ...
+/**
+ * @private
+ * @return {void}
+ **/
+xap.data.controller.Iterator.prototype.clearListenersAndIterator = function () {
+//		synchronized (this._session.getDocumentRegistry().getUiDocument().getDomSynchronizationObject()) {
+    for (var i = this._iteratedLocations.size() - 1; i >= 0; i--) {
+        /*Location*/
+        var loc = this._iteratedLocations.elementAt(i);
+		
+		// Deregister any child iterators, untie ourselves from them
+        if (loc instanceof xap.data.controller.Iterator) {
+            loc.setLocationListener(null);
+        } else {
+            if (loc instanceof xap.data.controller.XmlLocation) {
+			// Invalidate any XmlLocations untie ourselves from our children
+                (loc).invalidate();
+            }
+        }
+    }
+	// Clean up the parent reference, we do not want to be tied to the DOM!
+    this._parentLocation.setLocationListener(null);
+    this._parentLocation.invalidate();
+    this._parentLocation = null;
+//		}
+
+	// Remove this iterator from the iterator container
+    (xap.data.DataServiceFactory.getDataService(this._session)).getIteratorContainer().removeIterator(this);
+};
+/**
+ * @private
+ * @return {void}
+**/
+xap.data.controller.Iterator.prototype.invalidate = function () {
+//		synchronized (this._session.getDocumentRegistry().getUiDocument().getDomSynchronizationObject()) {
+    this.cleanupCreation();
+    if (this._context instanceof xap.data.datasource.AbstractDataSource) {
+        (this._context).removeListener(this);
+    } else {
+        if (this._context instanceof xap.data.controller.ContextFrame) {
+            (this._context).getDataSource().removeListener(this);
+        }
+    }
+    this._context = null;
+    if (this._locationListener != null) {
+        this._locationListener.locationInvalidated(this);
+        this._locationListener = null;
+    }
+			
+			// Stop listening to the parent location and invalidate it.
+    this._parentLocation.setLocationListener(null);
+    this._parentLocation.invalidate();
+    (xap.data.DataServiceFactory.getDataService(this._session)).getIteratorContainer().removeIterator(this);
+//		}
+};
+/*
+ * DataSetRetrievalListener interface methods.
+ *
+ * @public
+ * @return {void}
+ *
+ * @param location{Location}
+**/
+xap.data.controller.Iterator.prototype.locationInvalidated = function (location) {
+		// If our parent is removed, our life is over, remove ourselves from
+		// the data source on the data set if one has been retrieved...
+    if (location == this._parentLocation) {
+        this.invalidate();
+    }
+    this._iteratedLocations.removeElement(location);
+    if (this._iteratedLocations.size() == 0) {
+			// If this is a data set run, then we need to not invalidate!
+        if (!this._iterating) {
+            this.invalidate();
+        }
+    }
+};
+/**
+ * @public
+ * @return {void}
+ *
+ * @param listener{LocationListener}
+**/
+xap.data.controller.Iterator.prototype.setLocationListener = function (listener) {
+    this._locationListener = listener;
+};
+/**
+ * @public
+ * @return {void}
+**/
+xap.data.controller.Iterator.prototype.remove = function () {
+    this.invalidate();
+};
+/**
+ * This method and isDataRetrievalListener
+ * will be used by the data source to determine
+ * which sort of result set to expect
+ * Their return values will be NOT'd in
+ * the <code>Binding</code> class's implementation.
+ * @return true
+**/
+xap.data.controller.Iterator.prototype.isDataSetRetrievalListener = function () {
+    return true;
+};
+/**
+ * This method and isDataSetRetrievalListener
+ * will be used by the data source to determine
+ * which sort of result set to expect
+ * Their return values will be NOT'd in
+ * the <code>Binding</code> class's implementation.
+ * @return false
+**/
+xap.data.controller.Iterator.prototype.isDataRetrievalListener = function () {
+    return false;
+};
+
+
+	
+//-----------------------------------------------------------------------
+// Private Class:
+//-----------------------------------------------------------------------
+/**
+ * This task is used from iterateOverDataSet() method to schedule ui 
+ * updates unfreeze. See comments in the above method for more information.
+ */
+/**
+ * @private
+ * @constructor
+ * @param aSession{xap.session.ClientSession}
+**/
+xap.data.controller.Iterator.prototype.UiUpdatesUnfreezeTask = new function (aSession) {
+    this._session = aSession;
+};
+Xap.setupClassAsSubclassOf("xap.data.controller.Iterator.prototype.UiUpdatesUnfreezeTask", "Object");
+/**
+ * @public
+ * @return {void}
+**/
+xap.data.controller.Iterator.prototype.UiUpdatesUnfreezeTask.prototype.run = function () {
+    this._session.getDisplayService().freezeUiUpdates(false);
+};
+

Added: incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js?view=auto&rev=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js (added)
+++ incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js Sun Oct  1 00:23:49 2006
@@ -0,0 +1,118 @@
+/*
+ * 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.controller.IteratorContainerImpl");
+
+Xap.require("xap.session.ClientSession");
+Xap.require("xap.session.Container");
+Xap.require("xap.util.Vector");
+
+xap.data.controller.IteratorContainerImpl = function (aSession) {
+	xap.session.Container.call(this, aSession);
+};
+Xap.setupClassAsSubclassOf("xap.data.controller.IteratorContainerImpl", "xap.session.Container");
+/*(non-Javadoc)
+ * @see com.nexaweb.data.controller.IteratorContainer#getNames()
+ *
+ * @public
+ * @return {String[]}
+ **/
+xap.data.controller.IteratorContainerImpl.prototype.getNames = function () {
+	return this.superclass.getNames.call(this);
+};
+/*(non-Javadoc)
+ * @see com.nexaweb.data.controller.IteratorContainer#addIterator(java.lang.String, com.nexaweb.data.controller.Iterator)
+ *
+ * @public
+ * @return {void}
+ *
+ * @param name{String}
+ * @param iterator{Iterator}
+ **/
+xap.data.controller.IteratorContainerImpl.prototype.addIterator = function (name, iterator) {
+	/*Vector*/
+	var v = this.superclass.get.call(this, name);
+	if (v == null) {
+		v = new xap.util.Vector();
+		this.superclass.put.call(this,name, v);
+	}
+	v.addElement(iterator);
+};
+/*(non-Javadoc)
+ * @see com.nexaweb.data.controller.IteratorContainer#getIterator(java.lang.String, com.nexaweb.data.datasource.DataSet)
+ *
+ * @public
+ * @return {Iterator}
+ *
+ * @param name{String}, 
+ * @param ds{DataSet}
+ **/
+xap.data.controller.IteratorContainerImpl.prototype.getIterator = function (name, ds) {
+	/*Vector*/
+	var v = this.superclass.get.call(this, name);
+	if (v != null) {
+		for (var i = 0; i < v.size(); i++) {
+			/*Iterator*/
+			var iterator = v.elementAt(i);
+			if (iterator.getDataSet() == ds) {
+				return iterator;
+			}
+		}
+	}
+	return null;
+};
+/* (non-Javadoc)
+	 * @see com.nexaweb.data.controller.IteratorContainer#getIterators(java.lang.String)
+	  *
+ * @public
+ * @return {Vector}
+ *
+ * @param name{String}
+**/
+xap.data.controller.IteratorContainerImpl.prototype.getIterators = function (name) {
+	return this.superclass.get.call(this, name);
+};
+/* (non-Javadoc)
+	 * @see com.nexaweb.data.controller.IteratorContainer#removeIterator(com.nexaweb.data.controller.Iterator)
+	  *
+ * @public
+ * @return {void}
+ *
+ * @param iterator{Iterator}
+**/
+xap.data.controller.IteratorContainerImpl.prototype.removeIterator = function (iterator) {
+	/*Vector*/
+	var v = this.getIterators(iterator.getName());
+	if (v != null) {
+		v.removeElement(iterator);
+		if (v.size() == 0) {
+			this.superclass.removeValue.call(this, v);
+		}
+	}
+};
+/* (non-Javadoc)
+	 * @see com.nexaweb.data.controller.IteratorContainer#removeIterators(java.lang.String)
+	  *
+ * @public
+ * @return {void}
+ *
+ * @param name{String}
+**/
+xap.data.controller.IteratorContainerImpl.prototype.removeIterators = function (name) {
+	this.superclass.remove.call(this, name);
+};
+

Added: incubator/xap/trunk/src/xap/data/controller/XmlLocation.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/XmlLocation.js?view=auto&rev=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/XmlLocation.js (added)
+++ incubator/xap/trunk/src/xap/data/controller/XmlLocation.js Sun Oct  1 00:23:49 2006
@@ -0,0 +1,119 @@
+/*
+ * 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.controller.XmlLocation");
+Xap.require("xap.xml.dom.Document");
+Xap.require("xap.xml.dom.XapElement");
+
+/**
+ * @fileoverview A generic XML value location.
+ * 
+ * @author dgennaco
+ * @constructor
+ * @param element{XapElement}
+**/
+xap.data.controller.XmlLocation = function(element) {
+	this._element = element;
+	// Need (in essence) a no-argument constructor
+	// so that one of these can be used as a prototype
+	// object, hence the test:
+	if( 
+		(typeof element != "undefined")
+			&&	(element != null) 
+		){	
+		this._element.addDocumentOwnershipListener(this);
+	}		
+};
+
+Xap.setupClassAsSubclassOf("xap.data.controller.XmlLocation", "Object");
+/**
+ * @protected {XapElement}
+**/
+xap.data.controller.XmlLocation.prototype._element = null;
+/**
+ * @private {LocationListener}
+**/
+xap.data.controller.XmlLocation.prototype._locationListener = null;
+/*
+ * DocumentOwnershipListener interface methods
+ */
+/**
+ * @public
+ * @return {void}
+ *
+ * @param document{Document}
+**/
+xap.data.controller.XmlLocation.prototype.onRemovedFromDocument = function (document) {
+	this.invalidate();
+};
+
+/**
+ * @public
+ * @return {void}
+ *
+ * @param document{Document}
+**/
+xap.data.controller.XmlLocation.prototype.onAddedToDocument = function (document) {
+		// NOOP
+};
+/**
+ * @public
+ * @return {void}
+**/
+xap.data.controller.XmlLocation.prototype.remove = function () {
+	this.invalidate();
+};
+/*
+ * End - DocumentOwnershipListener interface methods
+ */
+/*
+ * XML Location Interface methods
+ */
+/**
+ * @public
+ * @return {void}
+ *
+ * @param listener{LocationListener}
+**/
+xap.data.controller.XmlLocation.prototype.setLocationListener = function (listener) {
+	this._locationListener = listener;
+};
+/*
+ * END - XML Location Interface methods
+ */
+/**
+ * @public
+ * @return {String}
+**/
+xap.data.controller.XmlLocation.prototype.toString = function () {
+	return (this.superclass.toString.call(this) + "-->" + this._element.toString());
+};
+/**
+ * @protected
+ * @return {void}
+**/
+xap.data.controller.XmlLocation.prototype.invalidate = function () {
+	if (this._locationListener != null) {
+		this._locationListener.locationInvalidated(this);
+			// Since we are now invalid, clear the location listener.
+		this._locationListener = null;
+	}
+	this._element.removeDocumentOwnershipListener(this);
+};
+

Added: incubator/xap/trunk/src/xap/data/datasource/AbstractDataSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/AbstractDataSet.js?view=auto&rev=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/AbstractDataSet.js (added)
+++ incubator/xap/trunk/src/xap/data/datasource/AbstractDataSet.js Sun Oct  1 00:23:49 2006
@@ -0,0 +1,173 @@
+/*
+ * 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.
+ *
+ */
+/**
+ * An ease-of-use base class for DataSet implementations.
+ * 
+ * @author jmargaris
+ */
+Xap.provide("xap.data.datasource.AbstractDataSet"); 
+Xap.require("xap.data.datasource.DataSetFactory") ;
+
+
+//-----------------------------------------------------------------------
+// Constructors.
+//-----------------------------------------------------------------------
+/**
+ * @public
+ * @return {AbstractDataSet}
+ *
+ * @param query{String}
+ * @param source{DataSource}
+ * @param data{Object  }
+ **/
+xap.data.datasource.AbstractDataSet = function(query, source, data) {
+	this._data = data ;
+	this._query = query ;
+	this._dataSource = source ;
+};
+Xap.setupClassAsSubclassOf("xap.data.datasource.AbstractDataSet", "Object");
+
+//-----------------------------------------------------------------------
+// Class Methods.
+//-----------------------------------------------------------------------
+/**
+ * @public
+ * @return {DataSet}
+ *
+ * @param query{String}
+ * @param dataSource{DataSource}
+ * @param data{Object  }
+ **/
+xap.data.datasource.AbstractDataSet.getDataSet = function (query, dataSource, data) {
+	/*DataSet*/
+	var dataset = xap.data.datasource.DataSetFactory.getInstance().createDataSet(query, dataSource, data);
+	return dataset;
+};
+
+//-----------------------------------------------------------------------
+// Instance Variables.
+//-----------------------------------------------------------------------
+/**
+ * @private Object
+ **/
+xap.data.datasource.AbstractDataSet.prototype._data = new Array();
+/**
+ * @private String
+ **/
+xap.data.datasource.AbstractDataSet.prototype._query = null;
+/**
+ * @private DataSource
+ **/
+xap.data.datasource.AbstractDataSet.prototype._dataSource = null;
+
+	
+
+
+	
+//-----------------------------------------------------------------------
+// Abstract Methods.
+//-----------------------------------------------------------------------
+/**
+ * @see DataSet#size()
+ *
+ * @public
+ * @return {int}
+ **/
+xap.data.datasource.AbstractDataSet.prototype.size = function () {
+	return this._data.length;
+};
+/**
+ * Returns an Enumeration over the elements in this DataSet in proper 
+ * sequence.
+ *
+ * @return an Enumeration over the elements in this DataSet in proper 
+ * sequence.
+ *
+ * @public
+ * @return {abstract}
+ **/
+xap.data.datasource.AbstractDataSet.prototype.elements = function () {
+	return this._data.length;
+};
+/**
+ * @see DataSet#getData(int)
+ * Implemented by subclasses:
+ * @public
+ * @return {Enumeration}
+ **/
+xap.data.datasource.AbstractDataSet.prototype.getData = function (index) {
+};
+
+//-----------------------------------------------------------------------
+// DataSet Implementation.
+//-----------------------------------------------------------------------
+/**
+ * @see DataSet#getQuery()
+ *
+ * @public
+ * @return {String}
+ **/
+xap.data.datasource.AbstractDataSet.prototype.getQuery = function () {
+	return this._query;
+};
+/**
+ * @see DataSet#getDataSource()
+ *
+ * @public
+ * @return {DataSource}
+ **/
+xap.data.datasource.AbstractDataSet.prototype.getDataSource = function () {
+	return this._dataSource;
+};
+/**
+ * @see DataSet#isEmpty()
+ *
+ * @public
+ * @return {boolean }
+ **/
+xap.data.datasource.AbstractDataSet.prototype.isEmpty = function () {
+	return this.size() == 0;
+};
+
+
+//-----------------------------------------------------------------------
+// Protected Methods.
+//-----------------------------------------------------------------------
+/**
+ * Returns the ACTUAL underlying data object.  Modifying the returned
+ * object modifies the dataset.
+ *
+ * @return The underlying data object.
+ *
+ * @protected
+ * @return {Object}
+ **/
+xap.data.datasource.AbstractDataSet.prototype.getData = function () {
+	return this._data;
+};
+/**
+ * Sets the underlying data object.
+ * 
+ * @param o{Object} The underlying data to set.
+ *
+ * @protected
+ * @return {void}
+ **/
+xap.data.datasource.AbstractDataSet.prototype.setData = function (o) {
+	this._data = o;
+};
+

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=451723&r1=451722&r2=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js Sun Oct  1 00:23:49 2006
@@ -23,9 +23,11 @@
 Xap.require("xap.util.LogFactory");
 Xap.require("xap.util.ResourceDictionary");
 Xap.require("xap.util.Vector");
+Xap.require("xap.data.datasource.QueryRecord") ;
+
 
 // Xap.require("xap.plugin.data.controller.BindingType") ;
-// Xap.require("xap.plugin.data.controller.Context") ;
+// Xap.require("xap.plugin.data.controller.ContextFrame") ;
 // Xap.require("xap.client.netservice.HttpResponse") ;
 // Xap.require("xap.plugin.data.InitializationException") ;
 // Xap.require("xap.util.Log") ;
@@ -174,9 +176,9 @@
  **/
 xap.data.datasource.AbstractDataSource.prototype.destroy = function () {
 	/**/
-	var _boundQueries = new xap.util.Vector();
+	this._boundQueries = new xap.util.Vector();
 	/**/
-	var _postponedQueries = new xap.util.Vector();
+	this._postponedQueries = new xap.util.Vector();
 };
 /**
  * @see DataSource#getId()
@@ -197,7 +199,13 @@
  * @return {boolean}
  **/
 xap.data.datasource.AbstractDataSource.prototype.isSupported = function (type) {
-	return type == xap.data.controller.BindingType.ONE_TIME || type == xap.data.controller.BindingType.ONE_WAY;
+	//return type === xap.data.controller.BindingType.ONE_TIME || type === xap.data.controller.BindingType.ONE_WAY;
+	//TODO:  See why the above didn't work properly--- is, probably, find
+	//out where we introduced another another BindingType instance without meaning to do...but for now:
+	return type 
+			&& (type.getTypeId() == xap.data.controller.BindingType.ONE_WAY.getTypeId()
+				|| type.getTypeId() == xap.data.controller.BindingType.ONE_TIME.getTypeId()
+				) ;
 };
 /**
  * @see DataSource#getData(String, DataRetrievalListener)
@@ -229,7 +237,7 @@
  * @return {void}
  * @param query{String}
  * @param listener{DataRetrievalListener}
- * @param context{Context  }
+ * @param context{ContextFrame}
  * @throws DataAccessException, MalformedQueryException, UnsupportedBindingTypeException 
  **/
 xap.data.datasource.AbstractDataSource.prototype.getData = function (query, listener, context) {
@@ -243,7 +251,7 @@
  * @return {void}
  * @param query{String}
  * @param listener{RetrievalListener}
- * @param context{Context  }
+ * @param context{ContextFrame  }
  **/
 xap.data.datasource.AbstractDataSource.prototype.removeListener = function (query, listener, context) {
 	for (var i = 0; i < this._boundQueries.size(); i++) {
@@ -298,7 +306,7 @@
 			this._boundQueries.removeElementAt(i--);
 		}
 	}
-	for (var i = 0; i < _postponedQueries.size(); i++) {
+	for (var i = 0; i < this._postponedQueries.size(); i++) {
 		/*QueryRecord*/
 		var record = this._postponedQueries.elementAt(i);
 		if (record.getListener() == listener) {
@@ -327,7 +335,7 @@
  * @return {void}
  **/
 xap.data.datasource.AbstractDataSource.prototype.fireDataChanged = function () {
-	for (var i = 0; i < _dataChangeListeners.size(); i++) {
+	for (var i = 0; i < this._dataChangeListeners.size(); i++) {
 		(this._dataChangeListeners.elementAt(i)).onDataChanged(this);
 	}
 };
@@ -355,7 +363,7 @@
  **/
 xap.data.datasource.AbstractDataSource.prototype.fireOnDataRetrieveSucess = function () {
 	/*for (int*/
-	for (var i = 0; i < _asynchronouseDataSourceListeners.size(); i++) {
+	for (var i = 0; i < this._asynchronouseDataSourceListeners.size(); i++) {
 		(this._asynchronouseDataSourceListeners.elementAt(i)).onDataRequestCompleted(this);
 	}
 };
@@ -366,7 +374,7 @@
  **/
 xap.data.datasource.AbstractDataSource.prototype.fireOnDataRetrieveFailure = function (failureCause) {
 	/*for (int*/
-	for (var i = 0; i < _asynchronouseDataSourceListeners.size(); i++) {
+	for (var i = 0; i < this._asynchronouseDataSourceListeners.size(); i++) {
 		(this._asynchronouseDataSourceListeners.elementAt(i)).onDataRequestFailed(this, failureCause);
 	}
 };
@@ -443,7 +451,7 @@
  * @throws MalformedQueryException
  * @protected
  * @param query{String}
- * @param context{Context} 
+ * @param context{ContextFrame} 
  * @param listener{DataRetrievalListener}
  * @throws DataAccessException, MalformedQueryException;
  **/
@@ -461,7 +469,7 @@
  * @throws MalformedQueryException
  * @protected
  * @param query{String}
- * @param context{Context}
+ * @param context{ContextFrame}
  * @param listener{DataSetRetrievalListener  }
  * @throws DataAccessException, MalformedQueryException
  **/
@@ -586,12 +594,12 @@
  * @protected
  * @return {void}
  * @param query{String}
- * @param context{Context}
+ * @param context{ContextFrame}
  * @param listener{RetrievalListener  }
  **/
 xap.data.datasource.AbstractDataSource.prototype.addPostponedQuery = function (query, context, listener) {
 	/*QueryRecord*/
-	var queryRecord = new QueryRecord(query, context, listener);
+	var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
 	this._postponedQueries.addElement(queryRecord);
 };
 /**
@@ -714,7 +722,7 @@
  * @private
  * @return {void}
  * @param query{String}
- * @param context{Context}
+ * @param context{ContextFrame}
  * @param listener{RetrievalListener  }
  * @throws DataAccessException, MalformedQueryException,UnsupportedBindingTypeException
  **/
@@ -726,7 +734,7 @@
 	// changes
 	if (listener != null && listener.getBindingType() != xap.data.controller.BindingType.ONE_TIME) {
 		/*QueryRecord*/
-		var queryRecord = new QueryRecord(query, context, listener);
+		var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
 		this._boundQueries.addElement(queryRecord);
 	}
 	this.handleQuery(query, context, listener);
@@ -735,13 +743,13 @@
  * A helper method for calling appropriate handleX methods
  * @private * 
  * @param query
- * @param queryContext
+ * @param queryContextFrame
  * @param listener
  * @throws DataAccessException
  * @throws MalformedQueryException
  *
  * @param query{String}
- * @param queryContext{Context}
+ * @param queryContext{ContextFrame}
  * @param listener{RetrievalListener  }
  **/
 xap.data.datasource.AbstractDataSource.prototype.handleQuery = function (query, queryContext, listener) {

Modified: incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js?view=diff&rev=451723&r1=451722&r2=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js Sun Oct  1 00:23:49 2006
@@ -1,112 +1,126 @@
-/**
- * An implementation of a DataSet which is backed by an array.  
- *
- * @author Igor Kaplansky, mturyn
+/**
+ * An implementation of a DataSet which is backed by an array.  
+ *
+ * @author Igor Kaplansky, mturyn
  */
 Xap.provide("xap.data.datasource.ArrayDataSet");
-Xap.setupClassAsSubclassOf("xap.data.datasource.ArrayDataSet", "xap.data.datasource.AbstractDataSet");
-
-
-	//-----------------------------------------------------------------------
-	// Constructors.
-	//-----------------------------------------------------------------------
-/**
- * @public
- * @return {ArrayDataSet}
- *
- * @param query{String}
- * @param source{DataSource}
- * @param dataArray{Object  }
+
+Xap.require("xap.data.datasource.AbstractDataSet") ;
+
+/**
+ * @public
+ * @return {ArrayDataSet}
+ *
+ * @param query{String}
+ * @param source{DataSource}
+ * @param dataArray{Object  }
 **/
 xap.data.datasource.ArrayDataSet = function (query, source, dataArray) {
-	xap.data.datasource.AbstractDataSet(this, query, source, dataArray);
+	xap.data.datasource.AbstractDataSet.call(this, query, source, dataArray);
 };
-/**
- * @see DataSet#size()
- *
- * @public
- * @return {int}
+
+
+Xap.setupClassAsSubclassOf("xap.data.datasource.ArrayDataSet", "xap.data.datasource.AbstractDataSet");
+
+
+	//-----------------------------------------------------------------------
+	// Constructors.
+	//-----------------------------------------------------------------------
+
+/**
+ * @see DataSet#size()
+ *
+ * @public
+ * @return {int}
 */
 xap.data.datasource.ArrayDataSet.prototype.size = function () {
-	return this.getArray().length;
+	return this._data.length;
 };
-/*
- * @see AbstractDataSet#elements()
- *
- * @public
- * @return {Enumeration}
-*/
-//xap.data.datasource.ArrayDataSet.prototype.elements  = function() {
-//		return new ArrayEnumeration( getArray() );
+/*
+ * @see AbstractDataSet#elements()
+ *
+ * @public
+ * @return {Enumeration}
+*/
+//xap.data.datasource.ArrayDataSet.prototype.elements  = function() {
+//		return new ArrayEnumeration( this.getArray() );
 //	}
-/**
- * @see DataSet#getData(int)
- *
- * @public
- * @param index{int} Index into the data set, here held as an array.
- * @return {Object}
+/**
+ * @see DataSet#getData(int)
+ *
+ * @public
+ * @param index{int} Index into the data set, here held as an array.
+ * @return {Object}
 **/
 xap.data.datasource.ArrayDataSet.prototype.getData = function (index) {
-	return Array.get(this.getArray(), index);
-};
-
-	//-----------------------------------------------------------------------
-	// Protected Methods.
+	var result = null ;
+	// Have to be careful here; if you were to use "!index",
+	// that would do damage if the index were 0....
+	if( (typeof index=="undefined") || index==null){
+		result = this._data ;
+	} else {
+		result = this._data[index] ;
+	}
+	return result ;
+};
+
+	//-----------------------------------------------------------------------
+	// Protected Methods.
 	//-----------------------------------------------------------------------
-/**
- * @return The underlying array.
- *
- * @protected
- * @return {Object}
+/**
+ * @return The underlying array.
+ *
+ * @protected
+ * @return {Object}
 **/
 xap.data.datasource.ArrayDataSet.prototype.getArray = function () {
-	return getData();
-};
-	
-//-----------------------------------------------------------------------
-// Private Classes.
-//-----------------------------------------------------------------------
-//
-// Doesn't appear to be necessary, yet....
-//
-//
-//Xap.setupClassAsSubclassOf("xap.data.datasource.ArrayEnumeration","Enumeration") ;
-//
-//		/*private Object*/
-//var this._array =  null;
-//		/*private int*/
-//var this._size =  0;
-//		/*private int*/
-//var this._currentIndex =  0;
-//
-//		ArrayEnumeration( Object array ) {
-//			this._array = array;
-//			this._size = Array.getLength( array );
-//			this._currentIndex = 0;
-//		}
-//
-///**
-// * @public
-// * @return {boolean}
-//**/
-//xap.data.datasource.ArrayDataSet.prototype.hasMoreElements = function() {
-//			return this._currentIndex < this._size;
-//		}
-//
-///**
-// * @public
-// * @return {Object}
-//**/
-//xap.data.datasource.ArrayDataSet.prototype.nextElement = function() {
-//			if( this._currentIndex >= this._size ) {
-//				throw new NoSuchElementException(
-//					"Array does not contain any more elements" );
-//			}
-//			/*Object*/
-//var o =  Array.get( this._array, this._currentIndex );
-//			this._currentIndex++;
-//			return o;
-//		}
-//	}
+	return _data ;
+};
+	
+//-----------------------------------------------------------------------
+// Private Classes.
+//-----------------------------------------------------------------------
+//
+// Doesn't appear to be necessary, yet....
+//
+//
+//Xap.setupClassAsSubclassOf("xap.data.datasource.ArrayEnumeration","Enumeration") ;
+//
+//		/*private Object*/
+//var this._array =  null;
+//		/*private int*/
+//var this._size =  0;
+//		/*private int*/
+//var this._currentIndex =  0;
+//
+//		ArrayEnumeration( Object array ) {
+//			this._array = array;
+//			this._size = Array.getLength( array );
+//			this._currentIndex = 0;
+//		}
+//
+///**
+// * @public
+// * @return {boolean}
+//**/
+//xap.data.datasource.ArrayDataSet.prototype.hasMoreElements = function() {
+//			return this._currentIndex < this._size;
+//		}
+//
+///**
+// * @public
+// * @return {Object}
+//**/
+//xap.data.datasource.ArrayDataSet.prototype.nextElement = function() {
+//			if( this._currentIndex >= this._size ) {
+//				throw new NoSuchElementException(
+//					"Array does not contain any more elements" );
+//			}
+//			/*Object*/
+//var o =  Array.get( this._array, this._currentIndex );
+//			this._currentIndex++;
+//			return o;
+//		}
+//	}
 //}
 

Added: incubator/xap/trunk/src/xap/data/datasource/DataSetFactory.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/DataSetFactory.js?view=auto&rev=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/DataSetFactory.js (added)
+++ incubator/xap/trunk/src/xap/data/datasource/DataSetFactory.js Sun Oct  1 00:23:49 2006
@@ -0,0 +1,102 @@
+
+/*
+ * 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.require("xap.util.Vector");
+
+/**
+ * DataSetFactory maps data object types to the appropriate DataSet instances.
+ * Note the special logic in #createDataSet() method to make sure this class 
+ * will work in 1.1 and 1.2+ compliant JVMs.
+ * 
+ * @author Igor Kaplansky
+ */
+/**
+ * @private
+ * @constructor
+**/
+xap.data.datasource.DataSetFactory = function () {
+		// private no-op constructor, cannot externally
+		// instantiate this factor---use single instance kept
+		// on class
+};
+Xap.setupClassAsSubclassOf("xap.data.datasource.DataSetFactory", "Object");
+
+	//-----------------------------------------------------------------------
+	// Class Variables.
+	//-----------------------------------------------------------------------
+/*private static DataSetFactory*/
+xap.data.datasource.DataSetFactory.s_instance = new xap.data.datasource.DataSetFactory();
+	
+	//-----------------------------------------------------------------------
+	// Class Methods.
+	//-----------------------------------------------------------------------
+/**
+ * @public
+ * @return {DataSetFactory}
+**/
+xap.data.datasource.DataSetFactory.getInstance = function () {
+	return xap.data.datasource.DataSetFactory.s_instance;
+};
+
+
+	
+//-----------------------------------------------------------------------
+// Public Methods.
+//-----------------------------------------------------------------------
+/**
+ * Creates a DataSet object corresponding to the type of the 'data' 
+ * argument. 
+ * 
+ * <p/>
+ * 
+ * @param query - dataset specific query
+ * @param dataSource - the datasource that generated the data
+ * @param data - the actual data object returned as a result of evaluating
+ *			   the query.
+ * @return DataSet - the dataset of a type corresponding to the type 
+ *				   of the data it wraps. 
+ *
+ * @public
+ * @return {DataSet}
+ *
+ * @param query{String}
+ * @param dataSource{DataSource}
+ * @param data{Object}
+**/
+xap.data.datasource.DataSetFactory.prototype.createDataSet = function (query, dataSource, data) {
+	if (data == null) {
+		var arr = new Array(0);
+		Xap.require("xap.data.datasource.ArrayDataSet") ;
+		return new xap.data.datasource.ArrayDataSet(query, dataSource, arr);
+	} else {
+		if (data instanceof Array) {
+			Xap.require("xap.data.datasource.ArrayDataSet") ;
+			return new xap.data.datasource.ArrayDataSet(query, dataSource, data);
+		} else {
+			if (data instanceof xap.util.Vector) {
+				Xap.require("xap.data.datasource.VectorDataSet") ;
+				return new xap.data.datasource.VectorDataSet(query, dataSource, data);
+			} else {
+				/*Vector*/
+				var arr = [data] ;
+				Xap.require("xap.data.datasource.ArrayDataSet") ;				
+				return new xap.data.datasource.ArrayDataSet(query, dataSource, arr);
+			}
+		}
+	}
+};
+

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=451723&r1=451722&r2=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js Sun Oct  1 00:23:49 2006
@@ -17,6 +17,7 @@
 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 () {
@@ -66,6 +67,74 @@
  * @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 = query.replace(/<currentElement>/g,"contextObject") ;
+		theScript = theScript.replace(/<currentIndex>/g,"currentIndex") ;		
+		theScript = theScript.replace(/<currentCount>/g,"currentCount") ;		
+		theScript = theScript.replace(/<totalCount>/g,"totalCount") ;		
+		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 )
+ *
+ * @protected
+ * @return {void}
+ *
+ * @param query{String}
+ * @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();
@@ -79,15 +148,16 @@
 		try {			
 			theData = eval(theScript) ;
 		} catch (anException){
-			throw new xap.util.Exception("Could not evaluate: '"
+			throw new xap.util.Exception(
+			"JavascriptDataSource.handleDataSetQuery:Could not evaluate: '"
 											+ theScript
 											+"'"
 											) ;
 		}
-		
-		
-		listener.dataRetrieved(query, theData, context);
+		/*DataSet*/
+		var dataset 
+			= xap.data.datasource.AbstractDataSet.getDataSet(query, this, theData);		
+		listener.dataSetRetrieved(query, dataset, context);
 	}
 };
-
 

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=451723&r1=451722&r2=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js Sun Oct  1 00:23:49 2006
@@ -165,11 +165,11 @@
 		throw new xap.util.Exception("ObjectDataSource.setSource: no data. ");
 	}
 	/*Object*/
-	var oldSource = getSource();
+	var oldSource = this.getSource();
 	if (oldSource != null) {
 		removePropertyChangeListener(oldSource, this.getPropertyChangeListener());
 	}
-	this.addPropertyChangeListener(data, getPropertyChangeListener());
+	this.addPropertyChangeListener(data, this.getPropertyChangeListener());
 	this.superclass.setSource.call(this, data);
 	if (this.getRefreshOnPropertyChange()) {
 		try {
@@ -230,7 +230,7 @@
  * @return {Object}
 **/
 xap.data.datasource.ObjectDataSource.prototype.getObject = function () {
-	return getSource();
+	return this.getSource();
 };
 	//-----------------------------------------------------------------------
 	// Protected Methods.
@@ -251,7 +251,8 @@
  * @
 		Object
 **/
-	xap.data.datasource.ObjectDataSource.prototype.contextObject = getSource();
+	xap.data.datasource.ObjectDataSource.prototype.contextObject 
+				= this.getSource();
 	if (context != null) {
 		contextObject = context.getData();
 	}
@@ -276,17 +277,17 @@
 **/
 xap.data.datasource.ObjectDataSource.prototype.handleDataSetQuery = function (query, context, listener) {
 	/*Object*/
-	var contextObject = getSource();
+	var contextObject = this.getSource();
 	if (context != null) {
 		contextObject = context.getData();
 	}
 	if (contextObject == null) {
-		addPostponedQuery(query, context, listener);
+		this.addPostponedQuery(query, context, listener);
 	} else {
 		/*Object*/
 		var data = OgnlPath.evaluate(query, contextObject);
 		/*DataSet*/
-		var dataset = AbstractDataSet.getDataSet(query, this, data);
+		var dataset = xap.data.datasource.AbstractDataSet.getDataSet(query, this, data);
 		listener.dataSetRetrieved(query, dataset, context);
 	}
 };
@@ -368,7 +369,7 @@
 	try {
 		if (object != null && listener != null) {
 			/*Class*/
-			var c = object.getClass();
+			var c = object ; //.getClass();
 			/*Method*/
 			var m = c["removePropertyChangeListener"];
  						//new Class[]{ PropertyChangeListener.class });

Added: incubator/xap/trunk/src/xap/data/datasource/VectorDataSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/VectorDataSet.js?view=auto&rev=451723
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/VectorDataSet.js (added)
+++ incubator/xap/trunk/src/xap/data/datasource/VectorDataSet.js Sun Oct  1 00:23:49 2006
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ *
+ */
+/**
+ * An implementation of a DataSet which is backed by a Vector instance.  
+ *
+ * @author Igor Kaplansky, mturyn
+ */
+Xap.provide("xap.data.datasource.VectorDataSet");
+Xap.require("xap.util.Vector");
+Xap.require("xap.data.datasource.AbstractDataSet"); 
+
+/**
+* A DataSet implementation which is backed by a Vector.
+*
+* 
+* @author jconstantine
+*/
+
+//-----------------------------------------------------------------------
+// Constructors.
+//-----------------------------------------------------------------------
+/**
+* @public
+* @return {VectorDataSet}
+*
+* @param query{String}
+* @param source{DataSource}
+* @param data{Vector  }
+**/
+xap.data.datasource.VectorDataSet = function (query, source, data) {
+	xap.data.datasource.AbstractDataSet.call(this, query, source, data);
+};
+Xap.setupClassAsSubclassOf("xap.data.datasource.VectorDataSet", "AbstractDataSet");
+/**
+* @see DataSet#size()
+*
+* @public
+* @return {int}
+**/
+xap.data.datasource.VectorDataSet.prototype.size = function () {
+	return this.getVector().size();
+};
+/**
+* @see AbstractDataSet#elements()
+*
+* @public
+* @return {Enumeration}
+**/
+xap.data.datasource.VectorDataSet.prototype.elements = function () {
+	return this.getVector().elements();
+};
+/**
+* @see DataSet#getData(int)
+* @param index{int}
+* @public
+* @return {Object}
+**/
+xap.data.datasource.VectorDataSet.prototype.getData = function (index) {
+	return this.getVector().elementAt(index);
+};
+
+//-----------------------------------------------------------------------
+// Protected Methods.
+//-----------------------------------------------------------------------
+/**
+* Returns the underlying Vector.
+*
+* @return The underlying Vector.
+*
+* @protected
+* @return {Vector}
+**/
+xap.data.datasource.VectorDataSet.prototype.getVector = function () {
+	return (this.getData());
+};
+

Modified: incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js?view=diff&rev=451723&r1=451722&r2=451723
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js Sun Oct  1 00:23:49 2006
@@ -690,12 +690,12 @@
 //     	}
 //
 //     	// little optimization
-//     	if ( attributeName.equals(XmlTokens.ID) || attributeName.equals(XmlTokens.TEXT) ) return null;
+//     	if ( attributeName == xap.xml.XmlTokens.ID || attributeName == XmlTokens.TEXT ) return null;
 //     	
 //     	if ( UrlPathUtil.isFullyFormattedUrl(attributeValue)) return null;
 //     	
 //     	for ( int i = 0; i<XmlTokens.ON_EVENT_NAMES.length; i++){
-//     		if ( XmlTokens.ON_EVENT_NAMES[i].equals(attributeName) ){
+//     		if ( XmlTokens.ON_EVENT_NAMES[i] == attributeName ){
 //     			try {
 //					return tagHandler.createQualifiedUrlAsString(attributeValue);
 //				} catch (MalformedURLException e) {
@@ -705,7 +705,7 @@
 //     	}
 //     	
 //     	for ( int i = 0; i<IMG_TAG_NAMES.length; i++){
-//     		if ( IMG_TAG_NAMES[i].equals(attributeName)){
+//     		if ( IMG_TAG_NAMES[i] == attributeName ){
 //     			try {
 //					return tagHandler.createQualifiedUrlAsString(attributeValue);
 //				} catch (MalformedURLException e) {