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 jm...@apache.org on 2007/02/13 01:01:31 UTC
svn commit: r506785 - in /incubator/xap/trunk:
codebase/src/xap/bridges/dojo/ codebase/src/xap/bridges/xap/
codebase/src/xap/data/ codebase/src/xap/data/controller/
codebase/src/xap/data/datasource/ codebase/src/xap/session/
codebase/src/xap/taghandlin...
Author: jmargaris
Date: Mon Feb 12 17:01:29 2007
New Revision: 506785
URL: http://svn.apache.org/viewvc?view=rev&rev=506785
Log:
whole bunch of cleanup - require/provide, removed
vector class, removed unused methods, etc
Modified:
incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextAreaBridge.js
incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextFieldBridge.js
incubator/xap/trunk/codebase/src/xap/bridges/dojo/WindowBridge.js
incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js
incubator/xap/trunk/codebase/src/xap/data/DataFramework.js
incubator/xap/trunk/codebase/src/xap/data/controller/Binding.js
incubator/xap/trunk/codebase/src/xap/data/controller/ContextStack.js
incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js
incubator/xap/trunk/codebase/src/xap/data/controller/IteratorContainerImpl.js
incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js
incubator/xap/trunk/codebase/src/xap/data/datasource/DataSetFactory.js
incubator/xap/trunk/codebase/src/xap/data/datasource/ObjectDataSource.js
incubator/xap/trunk/codebase/src/xap/data/datasource/SimpleDocumentDataSource.js
incubator/xap/trunk/codebase/src/xap/session/ClientSession.js
incubator/xap/trunk/codebase/src/xap/taghandling/AbstractTagImpl.js
incubator/xap/trunk/codebase/src/xap/util/ArrayHelper.js
incubator/xap/trunk/codebase/src/xap/util/XmlUtils.js
incubator/xap/trunk/codebase/src/xap/widgets/Label.js
incubator/xap/trunk/codebase/src/xap/widgets/dojo/ComboBoxTextField.js
incubator/xap/trunk/codebase/src/xap/xml/NamespaceHandlerManager.js
incubator/xap/trunk/codebase/src/xap/xml/dom/Document.js
incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js
incubator/xap/trunk/codebase/src/xap/xml/dom/XapElementRes.js
incubator/xap/trunk/codebase/src/xap/xml/sax/SaxParser.js
incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js
incubator/xap/trunk/unittests/testsrc/xap/util/_TestXmlUtils.html
incubator/xap/trunk/unittests/testsrc/xap/xml/_TestElement.js
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextAreaBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextAreaBridge.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextAreaBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextAreaBridge.js Mon Feb 12 17:01:29 2007
@@ -94,7 +94,7 @@
this.lastKeyCode = event.keyCode ;
//TODO stop writing back the attribute and ONLY do the dom node
- this.writeBackAttribute(xap.xml.XmlTokens.TEXT,text);
+ this.writeBackAttribute('text',text);
//TODO this is really slow to do this every time, maybe we should do it
//only when we NEED to have it ready, for example before we fire an event
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextFieldBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextFieldBridge.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextFieldBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/TextFieldBridge.js Mon Feb 12 17:01:29 2007
@@ -29,7 +29,6 @@
Xap.require("xap.widgets.dojo.TextField");
Xap.require("xap.session.ClientEvent");
Xap.require("dojo.html") ;
-Xap.require("xap.xml.XmlTokens") ;
Xap.require("xap.widgets.Label");//needed for styleSet function
/**
* @fileoverview
@@ -98,7 +97,7 @@
clientEvent.text = text;
clientEvent.originalEvent = event ;
this.lastKeyCode = event.keyCode ;
- this.writeBackAttribute(xap.xml.XmlTokens.TEXT,text);
+ this.writeBackAttribute('text',text);
this.fireEvent("onTextChange",null,null,clientEvent);
}
}
@@ -113,7 +112,7 @@
var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());
- this.writeBackAttribute(xap.xml.XmlTokens.TEXT,newText);
+ this.writeBackAttribute('text',newText);
clientEvent.text = newText;
clientEvent.originalEvent = event ;
this.fireEvent("onEdit",null,null,clientEvent);
@@ -135,7 +134,7 @@
var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());
clientEvent.text = newText;
this.setTextAttribute(newText) ;
- this.writeBackAttribute(xap.xml.XmlTokens.TEXT,newText);
+ this.writeBackAttribute('text',newText);
this.fireEvent("onEdit",null,null,clientEvent) ;
}
}
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/WindowBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/WindowBridge.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/WindowBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/WindowBridge.js Mon Feb 12 17:01:29 2007
@@ -29,7 +29,6 @@
Xap.require("xap.session.ClientEvent");
Xap.require("xap.util.Event");
Xap.require('xap.bridges.dojo.DojoWidgetBridge');
-Xap.require("xap.xml.XmlTokens") ;
Xap.require("xap.util.LayoutUtils") ;
@@ -82,15 +81,15 @@
// (on start-up, set[Min|Max]imizedAttribute() gets
// called if either of those attributes are set to
- // xap.xml.XmlTokens.TRUE, but neither works at that time, so do it by hand:)
+ // true, but neither works at that time, so do it by hand:)
// Set max xor min, if desired, as early as possible:
- if( this.getElement().getAttribute(xap.xml.XmlTokens.MINIMIZED) == xap.xml.XmlTokens.TRUE){
- this.setMinimizedAttribute(xap.xml.XmlTokens.TRUE) ;
- } else if( this.getElement().getAttribute(xap.xml.XmlTokens.MAXIMIZED) == xap.xml.XmlTokens.TRUE){
- if( this.getPeer().windowState == xap.xml.XmlTokens.MINIMIZED){
+ if( this.getElement().getAttribute('minimized') == 'true'){
+ this.setMinimizedAttribute('true') ;
+ } else if( this.getElement().getAttribute('maximized') == 'true'){
+ if( this.getPeer().windowState == 'minimized'){
this.wasMaximisedFromMinimized = true ;
}
- this.setMaximizedAttribute(xap.xml.XmlTokens.TRUE) ;
+ this.setMaximizedAttribute('true') ;
}
// Yet another place where an attribute
@@ -270,16 +269,16 @@
/** XML attribute set method for "maximized" */
xap.bridges.dojo.WindowBridge.prototype.setMaximizedAttribute = function(value){
- if( value == xap.xml.XmlTokens.TRUE){
- if( this.getPeer().windowState == xap.xml.XmlTokens.MINIMIZED){
+ if( value == 'true'){
+ if( this.getPeer().windowState == 'minimized'){
this.wasMaximisedFromMinimized = true ;
}
- if (this.getElement().getAttribute(xap.xml.XmlTokens.MAXIMIZABLE)
- != xap.xml.XmlTokens.FALSE
+ if (this.getElement().getAttribute('maximizable')
+ != 'false'
){
this.getPeer().maximizeWindow({});
- this.writeBackAttribute(xap.xml.XmlTokens.MINIMIZED,xap.xml.XmlTokens.FALSE);
- this.writeBackAttribute(xap.xml.XmlTokens.MAXIMIZED,xap.xml.XmlTokens.TRUE);
+ this.writeBackAttribute('minimized','false');
+ this.writeBackAttribute('maximized','true');
}
} else {
this.restoreWindow() ;
@@ -288,14 +287,14 @@
/** XML attribute set method for "minimized" */
xap.bridges.dojo.WindowBridge.prototype.setMinimizedAttribute = function(value){
- if( value == xap.xml.XmlTokens.TRUE){
- if (this.getElement().getAttribute(xap.xml.XmlTokens.MINIMIZABLE)
- != xap.xml.XmlTokens.FALSE
+ if( value == 'true'){
+ if (this.getElement().getAttribute('minimizable')
+ != 'false'
){
this.getPeer().minimizeWindow({});
}
- this.writeBackAttribute(xap.xml.XmlTokens.MINIMIZED,xap.xml.XmlTokens.TRUE);
- this.writeBackAttribute(xap.xml.XmlTokens.MAXIMIZED,xap.xml.XmlTokens.FALSE);
+ this.writeBackAttribute('minimized','true');
+ this.writeBackAttribute('maximized','false');
} else {
this.restoreWindow() ;
}
@@ -303,10 +302,10 @@
xap.bridges.dojo.WindowBridge.prototype.toggleMaximized = function(){
- if (this.getPeer().windowState != xap.xml.XmlTokens.MAXIMIZED){
- this.setMaximizedAttribute( xap.xml.XmlTokens.TRUE ) ;
- this.writeBackAttribute(xap.xml.XmlTokens.MINIMIZED,xap.xml.XmlTokens.FALSE);
- this.writeBackAttribute(xap.xml.XmlTokens.MAXIMIZED,xap.xml.XmlTokens.TRUE);
+ if (this.getPeer().windowState != 'maximized'){
+ this.setMaximizedAttribute( 'true' ) ;
+ this.writeBackAttribute('minimized','false');
+ this.writeBackAttribute('maximized','true');
} else {
this.restoreWindow() ;
}
@@ -318,16 +317,16 @@
**/
xap.bridges.dojo.WindowBridge.prototype.restoreWindow = function(){
if (
- (this.getPeer().windowState == xap.xml.XmlTokens.MAXIMIZED)
+ (this.getPeer().windowState == 'maximized')
&& this.wasMaximisedFromMinimized
){
this.wasMaximisedFromMinimized = false ;
// go back to minimised:
- this.setMinimizedAttribute(xap.xml.XmlTokens.TRUE) ;
+ this.setMinimizedAttribute('true') ;
} else {
this.getPeer().restoreWindow({}) ;
- this.writeBackAttribute(xap.xml.XmlTokens.MINIMIZED,xap.xml.XmlTokens.FALSE);
- this.writeBackAttribute(xap.xml.XmlTokens.MAXIMIZED,xap.xml.XmlTokens.FALSE);
+ this.writeBackAttribute('minimized','false');
+ this.writeBackAttribute('maximized','false');
}
}
@@ -335,20 +334,20 @@
xap.bridges.dojo.WindowBridge.prototype.setResizableAttribute = function(val){
if( val && val != "false"){
this.getPeer().enableResizeHandle() ;
- this.writeBackAttribute(xap.xml.XmlTokens.RESIZABLE,xap.xml.XmlTokens.TRUE);
- this.resizable=xap.xml.XmlTokens.TRUE ;
+ this.writeBackAttribute('resizable','true');
+ this.resizable='true' ;
} else if (!val || val=="false"){
this.getPeer().disableResizeHandle() ;
//IMPORTANT why are these being written back? Aren't they jus set already?
- this.writeBackAttribute(xap.xml.XmlTokens.RESIZABLE,xap.xml.XmlTokens.FALSE);
- this.resizable=xap.xml.XmlTokens.FALSE ;
+ this.writeBackAttribute('resizable','false');
+ this.resizable='false' ;
}
}
xap.bridges.dojo.WindowBridge.prototype.setVisibleAttribute = function( val ){
- this.getPeer().setVisible(! (val==xap.xml.XmlTokens.FALSE) );
+ this.getPeer().setVisible(! (val=='false') );
}
@@ -376,7 +375,7 @@
}
xap.bridges.dojo.WindowBridge.prototype.setCenteredAttribute = function( val ){
- if( val == xap.xml.XmlTokens.TRUE ){
+ if( val == 'true' ){
this.center() ;
} else {
// use whatever explicit x/y we might have:
@@ -401,7 +400,7 @@
xap.bridges.dojo.WindowBridge.prototype.isCentered = function(){
- return this.getElement().getAttribute("centered") == xap.xml.XmlTokens.TRUE ;
+ return this.getElement().getAttribute("centered") == 'true' ;
}
xap.bridges.dojo.WindowBridge.prototype.setTitleAttribute = function(txt){
Modified: incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js Mon Feb 12 17:01:29 2007
@@ -26,7 +26,6 @@
Xap.provide("xap.bridges.xap.XapComboBoxBridge");
Xap.require("xap.bridges.dojo.DojoWidgetBridge");
Xap.require("xap.widgets.XapComboBox");
-Xap.require("xap.xml.XmlTokens");
Modified: incubator/xap/trunk/codebase/src/xap/data/DataFramework.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/DataFramework.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/DataFramework.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/DataFramework.js Mon Feb 12 17:01:29 2007
@@ -19,22 +19,24 @@
Xap.provide("xap.data.DataFramework");
+
+Xap.require("xap.session.ClientEvent");
+Xap.require("xap.session.ClientSession");
+Xap.require("xap.mco.ContainerLifeCycleObject");
+Xap.require("xap.session.DeclarativeArgumentParser");
Xap.require("xap.data.controller.Binding") ;
Xap.require("xap.session.Container") ;
-Xap.require("xap.data.controller.BindingType") ;
+Xap.require("xap.data.controller.BindingType") ;
Xap.require("xap.resolver.ResolutionInfo");
-Xap.require("xap.data.controller.IteratorContainerImpl");
-
/**
- * This class encapsulates all the data primitives available for a client session.
+ * Thisclass encapsulates all the data primitives available for a client session.
* It may be used to lookup bindings, formatters, data source, and validators.
*
* @author dgennaco
- * @author jmargaris
*/
-
+Xap.setupClassAsSubclassOf("xap.data.DataFramework", "xap.mco.ContainerLifeCycleObject");
/**
* @constructor
* @param sess{ClientSession}
@@ -44,104 +46,97 @@
this._session = sess;
this._dataSourceContainer = new xap.session.Container(sess);
this._bindingContainer = new xap.session.Container(sess);
-
+// TODO: use the appropriate containers---just
+// placeholders here to avoid follow-on errors.
this._formatterContainer = new xap.session.Container(sess);
this._iteratorContainer = new xap.data.controller.IteratorContainerImpl(sess);
- //add the dataSourceContainer to the container of containers
- //to support doing something like dataSource://myDataSource.do()
+ //add the dataSourceContainer to the container of containers
+ //to support doing something like dataSource://myDataSource.do()
this._session.addContainer("dataSource", this._dataSourceContainer);
this._session.addContainer("formatter", this._formatterContainer);
this._session.addContainer("binding", this._bindingContainer);
};
-
-
-/**
- * this.get the data service associated with the session.
- *
- * @param sess{ClientSession} The session.
- *
- * @return The data service.
- */
+/* private static final String */
+xap.data.DataFramework.MCO_ID = "DataService";
+/* private ClientSession */
+xap.data.DataFramework.prototype._session = null;
+/*private BindingContainerImpl */
+xap.data.DataFramework.prototype._bindingContainer = null;
+
+
+/*private BindingResolver */
+xap.data.DataFramework.prototype._bindingResolver = null;
+/*private IteratorContainerImpl */
+xap.data.DataFramework.prototype._iteratorContainer = null;
+/**
+ * this.get the data service associated with the session.
+ *
+ * @param sess{ClientSession} The session.
+ *
+ * @return The data service.
+ */
+/*public DataServiceImpl*/
xap.data.DataFramework.getDataService = function (sess) {
/*DataFramework*/
- var dataService = sess.getSystemContainer().get('DataService');
+ var dataService = /*(DataFramework)*/
+ sess.getSystemContainer().get(xap.data.DataFramework.MCO_ID);
if (!dataService) {
dataService = new xap.data.DataFramework(sess);
- sess.getSystemContainer().put('DataService', dataService);
-
+ sess.getSystemContainer().put(xap.data.DataFramework.MCO_ID, dataService);
/*McoArgumentParser*/
+
+ // TODO: Get the parser...
mcoParser = sess.getSystemContainer().get("McoArgumentParser");
- // add shortcuts to the binding methods.
+ // add shortcuts to the binding methods.
// ...so we can do the following:
- mcoParser.addFunctionShortcut("*", 'DataService.relativeBind');
- mcoParser.addFunctionShortcut("bind", 'DataService.bind');
+ mcoParser.addFunctionShortcut("*", xap.data.DataFramework.MCO_ID + ".relativeBind");
+ mcoParser.addFunctionShortcut("bind", xap.data.DataFramework.MCO_ID + ".bind");
}
return dataService;
};
-
/**
- * Returns the binding resolver for the data service.
- *
- * @return {xap.data.controller.BindingResolver} The binding resolver.
- */
+ * Returns the binding resolver for the data service. INTERNAL
+ * USE ONLY!
+ *
+ * @return the binding resolver.
+ */
+/*public BindingResolver*/
xap.data.DataFramework.prototype.getBindingResolver = function () {
return this._bindingResolver;
};
-
/**
- * Set the binding resolver for the data service.
- *
- * @param {xap.data.controller.BindingResolver} b The binding resolver
- */
+ * Set the binding resolver for the data service. INTERNAL
+ * USE ONLY!
+ *
+ * @param b{BindingResolver} the binding resolver
+ */
+/*public void*/
xap.data.DataFramework.prototype.setBindingResolver = function (b) {
this._bindingResolver = b;
};
-
/**
- * Returns the binding container for the data service.
- *
- * @return {xap.session.Container} The binding container.
- */
+ * Get the iterator container, INTERNAL USE ONLY!
+ * FUTURE expose this, and make a binding interface
+ *
+ * @return the iterator container
+ */
+/*public BindingContainer*/
xap.data.DataFramework.prototype.getBindingContainer = function () {
return this._bindingContainer;
};
-/**
- * Returns the binding container for the data service.
- *
- * @return {xap.data.controller.IteratorContainerImpl} The iterator container.
- */
-xap.data.DataFramework.prototype.getIteratorContainer = function () {
- return this._iteratorContainer;
-};
/**
- * Returns the formatter container for the data service.
- *
- * @return {xap.session.Container} The formatter container.
- */
-xap.data.DataFramework.prototype.getFormatterContainer = function () {
- return this._formatterContainer;
-};
-
-/**
- * Returns the data source container for the data service.
- *
- * @return {xap.session.Container} The data source container.
- */
-xap.data.DataFramework.prototype.getDataSourceContainer = function () {
- return this._dataSourceContainer;
-};
-
-
-xap.data.DataFramework.prototype.removedFromContainer = function () {
- this._bindingContainer.destroy();
- this._formatterContainer.destroy();
- this._dataSourceContainer.destroy();
- this._iteratorContainer.destroy();
+ * Get the iterator container, INTERNAL USE ONLY!
+ *
+ * @return the iterator container
+ */
+/*public IteratorContainer*/
+xap.data.DataFramework.prototype.getIteratorContainer = function () {
+ return this._iteratorContainer;
};
@@ -173,12 +168,72 @@
bindString,
this._session,
xap.data.controller.BindingType.ONE_TIME,
- null);
+ null
+ );
return this.bindBinding(binding);
};
+/*public void*/
+xap.data.DataFramework.prototype.unload = function () {
+ this._bindingContainer.destroy();
+ this._formatterContainer.destroy();
+ this_dataSourceContainer.destroy();
+ this._iteratorContainer.destroy();
+ xap.mco.ContainerLifeCycleObject.unload.call(this);
+};
+
+
+// Implementors of DataService
+/*private container */
+xap.data.DataFramework.prototype._formatterContainer = null;
+/*private container */
+xap.data.DataFramework.prototype._dataSourceContainer = null;
+
+/**
+ * The exception type used for all data framework exception
+ * reporting.
+
+ Fake it for now:
+
+ *public static final int
+ */
+// Implementor of DataService interface: xap.data.DataFramework.DATA_FRAMEWORK_EXCEPTION_TYPE = 10000;
+xap.data.DataFramework.DATA_FRAMEWORK_EXCEPTION_TYPE = "Data framework exception." ; //10000;
+//ExceptionContext.MAX_RANGE + 100;
+/**
+ * Get the formatter container.
+ *
+ * @return The container of formatters, never <code>null</code>.
+ *
+ * @public
+ * @return {FormatterContainer}
+ **/
+// Implementor of DataService interface: xap.data.DataFramework.prototype.getFormatterContainer = function () {
+xap.data.DataFramework.prototype.getFormatterContainer = function () {
+ return this._formatterContainer;
+};
+// Implementor of DataService interface: xap.data.DataFramework.prototype.setFormatterContainer = function (aContainer) {
+xap.data.DataFramework.prototype.setFormatterContainer = function (aContainer) {
+ this._formatterContainer = aContainer;
+};
+/**
+ * Get the data source container.
+ *
+ * @return The data source container, never <code>null</code>.
+ *
+ * @public
+ * @return {DataSourceContainer}
+ **/
+// Implementor of DataService interface: xap.data.DataFramework.prototype.getDataSourceContainer = function () {
+xap.data.DataFramework.prototype.getDataSourceContainer = function () {
+ return this._dataSourceContainer;
+};
+// Implementor of DataService interface: xap.data.DataFramework.prototype.setDataSourceContainer = function (aContainer) {
+xap.data.DataFramework.prototype.setDataSourceContainer = function (aContainer) {
+ this._dataSourceContainer = aContainer;
+};
xap.data.DataFramework.prototype.bind = function( stringOrBinding){
if ( typeof stringOrBinding == "string"){
Modified: incubator/xap/trunk/codebase/src/xap/data/controller/Binding.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/controller/Binding.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/controller/Binding.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/controller/Binding.js Mon Feb 12 17:01:29 2007
@@ -22,8 +22,8 @@
Xap.require("xap.util.TypeUtils");
Xap.require("xap.data.DataFramework");
Xap.require("xap.data.controller.BindingType");
-Xap.require("xap.util.Vector");
Xap.require("xap.data.controller.AttributeValueLocation");
+Xap.require("xap.util.ArrayHelper");
/*
@@ -36,7 +36,7 @@
*/
xap.data.controller.Binding = function(){
this._defaultValue = "";
- this._targets = new xap.util.Vector();
+ this._targets = [];
}
xap.data.controller.Binding.createDataSourceBinding =
@@ -212,9 +212,9 @@
*/
/*public*/
xap.data.controller.Binding.prototype.setData = function () {
- for (var i = 0; i < this._targets.size(); i++) {
+ for (var i = 0; i < this._targets.length; i++) {
/* TargetLocation */
- var target = this._targets.elementAt(i);
+ var target = this._targets[i];
target.setData(this._currentValue, this._session);
if (this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
target.invalidate();
@@ -246,19 +246,19 @@
* @param target{Location}
**/
xap.data.controller.Binding.prototype.addBindTarget = function (target) {
- this._targets.addElement(target);
+ this._targets.push(target);
target.setLocationListener(this);
};
/**
* @param target{Location}
**/
xap.data.controller.Binding.prototype.removeBindTarget = function (target) {
- this._targets.removeElement(target);
+ xap.util.ArrayHelper.removeElement(this._targets,target);
// if there are no targets left deregister from the data source associated
// with this binding.
// The data source is responsible for cleaning up one time bindings when
// the asynchronous call terminates, so never do that here.
- if (this._bindingType != xap.data.controller.BindingType.ONE_TIME && this._targets.size() == 0) {
+ if (this._bindingType != xap.data.controller.BindingType.ONE_TIME && this._targets.length == 0) {
// IMPORTANT REVISIT revisit this.the source should probably handle listeners removing themselves while
// it is looping through !!!
this._source.removeListener(this);
@@ -328,7 +328,7 @@
// otherwise, check to see if there are no targets set, which
// indicates we have not yet initiated ourselves as a ONE_WAY
// listener with the data source
- if (this._targets.size() == 0 || this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
+ if (this._targets.length == 0 || this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
// If there are already targets, then we're already waiting on some
// data, if we are in one-time mode, we should use this opportunity to
// make sure the latest data is the current data.
Modified: incubator/xap/trunk/codebase/src/xap/data/controller/ContextStack.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/controller/ContextStack.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/controller/ContextStack.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/controller/ContextStack.js Mon Feb 12 17:01:29 2007
@@ -27,18 +27,14 @@
*/
Xap.provide("xap.data.controller.ContextStack");
-//Xap.require("xap.data.datasource.DataAccessException");
-Xap.require("xap.util.Vector");
+Xap.require("xap.util.ArrayHelper");
xap.data.controller.ContextStack = function () {
+ /** @private */
+ this._contextStack = [];
};
-Xap.setupClassAsSubclassOf("xap.data.controller.ContextStack", "Object");
-/**
- * @private Vector
-**/
-xap.data.controller.ContextStack.prototype._contextStack = new xap.util.Vector(0);
/**
* Push a new context frame to the context stack.
*
@@ -50,7 +46,7 @@
* @param frame{ContextFrame}
**/
xap.data.controller.ContextStack.prototype.pushContext = function (frame) {
- this._contextStack.addElement(frame);
+ this._contextStack.push(frame);
};
/**
* Pop the current context from the context stack.
@@ -62,8 +58,8 @@
**/
xap.data.controller.ContextStack.prototype.popContext = function () {
/*ContextFrame*/
- var retFrame = this._contextStack.elementAt(this._contextStack.size() - 1);
- this._contextStack.removeElementAt(this._contextStack.size() - 1);
+ var retFrame = this._contextStack[(this._contextStack.length - 1)];
+ xap.util.ArrayHelper.removeElementAt(this._contextStack,this._contextStack.length - 1);
return retFrame;
};
/**
@@ -83,9 +79,9 @@
if (name == null || name.length == 0) {
return this.getCurrentContext();
}
- for (var i = 0; i < this._contextStack.size(); i++) {
+ for (var i = 0; i < this._contextStack.length; i++) {
/*ContextFrame*/
- var frame = this._contextStack.elementAt(i);
+ var frame = this._contextStack[i];
if ( name == frame.getName() ) {
return frame;
}
@@ -100,10 +96,10 @@
* @return {ContextFrame}
**/
xap.data.controller.ContextStack.prototype.getCurrentContext = function () {
- if (this._contextStack.size() == 0) {
+ if (this._contextStack.length == 0) {
return null;
}
- return this._contextStack.elementAt(this._contextStack.size() - 1);
+ return this._contextStack[this._contextStack.length- 1];
};
/**
* Convenience method to the the data set associated with the current
@@ -151,7 +147,7 @@
xap.data.controller.ContextStack.prototype.clone = function () {
/*ContextStack*/
var clone = new xap.data.controller.ContextStack();
- clone._contextStack = this._contextStack.clone();
+ clone._contextStack = xap.util.ArrayHelper.clone(this._contextStack);
return clone;
};
Modified: incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js Mon Feb 12 17:01:29 2007
@@ -26,6 +26,7 @@
Xap.require("xap.xml.dom.XapElement");
Xap.require("xap.data.controller.BindingResolver");
Xap.require("xap.data.controller.ContextFrame");
+Xap.require("xap.util.ArrayHelper");
/**
* 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
@@ -66,8 +67,18 @@
/*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);
+
+ /**
+ * 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
+ **/
+ this._iteratedLocations = [];
+ this._iteratedLocations.push(iteratorLocation);
+
/*DataFramework*/
var svc = xap.data.DataFramework.getDataService(this._session);
@@ -155,15 +166,8 @@
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 }
@@ -224,9 +228,9 @@
// 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);
+ var index = xap.util.ArrayHelper.indexOf(this._iteratedLocations,iteratorLocation);
+ xap.util.ArrayHelper.removeElementAt(this._iteratedLocations,index);
+ xap.util.ArrayHelper.insertElementAt(this._iteratedLocations,location, index);
location.setLocationListener(this);
iteratorLocation.setLocationListener(null);
}
@@ -238,9 +242,9 @@
* @param e{Element}
**/
xap.data.controller.Iterator.prototype.getChildLocation = function (e) {
- for (var i = 0; i < this._iteratedLocations.size(); i++) {
+ for (var i = 0; i < this._iteratedLocations.length; i++) {
/*Location*/
- var l = this._iteratedLocations.elementAt(i);
+ var l = this._iteratedLocations[i];
if (l instanceof xap.data.controller.ElementLocation) {
if ((l)._element == e) {
return l;
@@ -319,9 +323,9 @@
/*int*/
var iteratorLocationIndex = -1;
// first remove the old iterated nodes
- for (var i = this._iteratedLocations.size() - 1; i >= 0; i--) {
+ for (var i = this._iteratedLocations.length - 1; i >= 0; i--) {
/*Location*/
- var location = this._iteratedLocations.elementAt(i);
+ var location = this._iteratedLocations[i];
if (i == 0) { // Could be pricey, do this once only (last position)
if (location instanceof xap.data.controller.ElementLocation) {
iteratorLocationIndex = (location).getIndex();
@@ -354,7 +358,7 @@
xap.data.controller.Iterator.prototype.iterateOverDataSet = function (dataSet) {
// synchronized (this._session.getDocumentRegistry().getUiDocument().getDomSynchronizationObject()) {
this._context = dataSet.getDataSource();
- if (this._iteratedLocations.size() == 0) {
+ if (this._iteratedLocations.length == 0) {
// All contextual information about the iterator has
// been removed prior to a refresh call from a data source,
// invalidate and exit.
@@ -401,7 +405,7 @@
var childClone = child.deepClone();
if (this._bindingType != xap.data.controller.BindingType.ONE_TIME) {
location = new xap.data.controller.ElementLocation(childClone);
- this._iteratedLocations.addElement(location);
+ this._iteratedLocations.push(location);
}
this._parentElement.insertChildAt(insertIndex, childClone);
} else {
@@ -409,7 +413,7 @@
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);
+ this._iteratedLocations.push(location);
}
}
}
@@ -431,7 +435,7 @@
this._parentElement.insertChildAt(insertIndex, this._iteratorPlaceHolderElement);
/*xap.data.controller.ElementLocation*/
var location = new xap.data.controller.ElementLocation(this._iteratorPlaceHolderElement);
- this._iteratedLocations.addElement(location);
+ this._iteratedLocations.push(location);
location.setLocationListener(this);
insertIndex++;
}
@@ -510,9 +514,9 @@
**/
xap.data.controller.Iterator.prototype.clearListenersAndIterator = function () {
// synchronized (this._session.getDocumentRegistry().getUiDocument().getDomSynchronizationObject()) {
- for (var i = this._iteratedLocations.size() - 1; i >= 0; i--) {
+ for (var i = this._iteratedLocations.length - 1; i >= 0; i--) {
/*Location*/
- var loc = this._iteratedLocations.elementAt(i);
+ var loc = this._iteratedLocations[i];
// Deregister any child iterators, untie ourselves from them
if (loc instanceof xap.data.controller.Iterator) {
@@ -573,8 +577,8 @@
if (location == this._parentLocation) {
this.invalidate();
}
- this._iteratedLocations.removeElement(location);
- if (this._iteratedLocations.size() == 0) {
+ xap.util.ArrayHelper.removeElement(this._iteratedLocations,location);
+ if (this._iteratedLocations.length == 0) {
// If this is a data set run, then we need to not invalidate!
if (!this._iterating) {
this.invalidate();
Modified: incubator/xap/trunk/codebase/src/xap/data/controller/IteratorContainerImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/controller/IteratorContainerImpl.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/controller/IteratorContainerImpl.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/controller/IteratorContainerImpl.js Mon Feb 12 17:01:29 2007
@@ -21,7 +21,7 @@
Xap.require("xap.session.ClientSession");
Xap.require("xap.session.Container");
-Xap.require("xap.util.Vector");
+Xap.require("xap.util.ArrayHelper");
xap.data.controller.IteratorContainerImpl = function (aSession) {
xap.session.Container.call(this, aSession);
@@ -30,23 +30,21 @@
xap.data.controller.IteratorContainerImpl.prototype.addIterator = function (name, iterator) {
- /*Vector*/
- var v = this.superclass.get.call(this, name);
+ var v = this.get(name);
if (v == null) {
- v = new xap.util.Vector();
- this.superclass.put.call(this,name, v);
+ v = [];
+ this.put(name, v);
}
- v.addElement(iterator);
+ v.push(iterator);
};
xap.data.controller.IteratorContainerImpl.prototype.getIterator = function (name, ds) {
- /*Vector*/
- var v = this.superclass.get.call(this, name);
+ var v = this.get(name);
if (v != null) {
- for (var i = 0; i < v.size(); i++) {
+ for (var i = 0; i < v.length; i++) {
/*Iterator*/
- var iterator = v.elementAt(i);
+ var iterator = v[i];
if (iterator.getDataSet() == ds) {
return iterator;
}
@@ -57,23 +55,22 @@
xap.data.controller.IteratorContainerImpl.prototype.getIterators = function (name) {
- return this.superclass.get.call(this, name);
+ return this.get(name);
};
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);
+ xap.util.ArrayHelper.removeElement(v,iterator);
+ if (v.length == 0) {
+ this.removeValue(v);
}
}
};
xap.data.controller.IteratorContainerImpl.prototype.removeIterators = function (name) {
- this.superclass.remove.call(this, name);
+ this.remove.call(name);
};
Modified: incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js Mon Feb 12 17:01:29 2007
@@ -17,13 +17,14 @@
*
*/
Xap.provide("xap.data.datasource.AbstractDataSource");
+Xap.require("xap.mco.ContainerLifeCycleObject");
Xap.require("xap.requestservice.NetServiceListener");
Xap.require("xap.requestservice.RequestService");
Xap.require("xap.session.ClientSession");
Xap.require("xap.session.Container");
-Xap.require("xap.log.Logger");
+Xap.require("xap.util.LogFactory");
Xap.require("xap.util.ResourceDictionary");
-Xap.require("xap.util.Vector");
+Xap.require("xap.util.ArrayHelper");
Xap.require("xap.data.datasource.QueryRecord") ;
/**
@@ -48,10 +49,10 @@
* @author James Margaris
*/
xap.data.datasource.AbstractDataSource = function () {
- this._boundQueries = new xap.util.Vector();
- this._postponedQueries = new xap.util.Vector();
- this._asynchronousDataSourceListeners = new xap.util.Vector();
- this._dataChangeListeners = new xap.util.Vector();
+ this._boundQueries = [];
+ this._postponedQueries = [];
+ this._asynchronousDataSourceListeners = [];
+ this._dataChangeListeners = [];
}
@@ -77,10 +78,10 @@
xap.data.datasource.AbstractDataSource.prototype.destroy = function () {
- this._boundQueries = new xap.util.Vector();
- this._postponedQueries = new xap.util.Vector();
- this._asynchronousDataSourceListeners = new xap.util.Vector();
- this._dataChangeListeners = new xap.util.Vector();
+ this._boundQueries =[];
+ this._postponedQueries = [];
+ this._asynchronousDataSourceListeners = [];
+ this._dataChangeListeners = [];
}
/**
* @see DataSource#getDataSet(String, DataSetRetrievalListener)
@@ -114,18 +115,18 @@
* @return {void}
**/
xap.data.datasource.AbstractDataSource.prototype.removeListener = function (listener) {
- for (var i = 0; i < this._boundQueries.size(); i++) {
+ for (var i = 0; i < this._boundQueries.length; i++) {
/*QueryRecord*/
- var record = this._boundQueries.elementAt(i);
+ var record = this._boundQueries[i];
if (record.getListener() == listener) {
- this._boundQueries.removeElementAt(i--);
+ xap.util.ArrayHelper.removeElementAt(this._boundQueries, i--);
}
}
- for (var i = 0; i < this._postponedQueries.size(); i++) {
+ for (var i = 0; i < this._postponedQueries.length; i++) {
/*QueryRecord*/
- var record = this._postponedQueries.elementAt(i);
+ var record = this._postponedQueries[i];
if (record.getListener() == listener) {
- this._postponedQueries.removeElementAt(i--);
+ xap.util.ArrayHelper.removeElementAt(this._postponedQueries,i--);
}
}
};
@@ -133,8 +134,8 @@
* @param l{DataChangeListener}
**/
xap.data.datasource.AbstractDataSource.prototype.addDataChangeListener = function (l) {
- if (!this._dataChangeListeners.contains(l)) {
- this._dataChangeListeners.addElement(l);
+ if (! xap.util.ArrayHelper.contains(this._dataChangeListeners,l)) {
+ this._dataChangeListeners.push(l);
}
};
/**
@@ -143,15 +144,15 @@
* @return {void}
**/
xap.data.datasource.AbstractDataSource.prototype.removeDataChangeListener = function (l) {
- this._dataChangeListeners.removeElement(l);
+ xap.util.ArrayHelper.removeElement(this._dataChangeListeners,l);
};
/**
* @protected
* @return {void}
**/
xap.data.datasource.AbstractDataSource.prototype.fireDataChanged = function () {
- for (var i = 0; i < this._dataChangeListeners.size(); i++) {
- (this._dataChangeListeners.elementAt(i)).onDataChanged(this);
+ for (var i = 0; i < this._dataChangeListeners.length; i++) {
+ this._dataChangeListeners[i].onDataChanged(this);
}
};
/**
@@ -160,8 +161,8 @@
* @return {void}
**/
xap.data.datasource.AbstractDataSource.prototype.addAsynchronousDataSourceListener = function (l) {
- if (!this._asynchronousDataSourceListeners.contains(l)) {
- this._asynchronousDataSourceListeners.addElement(l);
+ if (!xap.util.ArrayHelper.contains(this._asynchronousDataSourceListeners,l)) {
+ this._asynchronousDataSourceListeners.push(l);
}
};
/**
@@ -170,7 +171,7 @@
* @param l{AsynchronousDataSourceListener}
**/
xap.data.datasource.AbstractDataSource.prototype.removeAsynchronousDataSourceListener = function (l) {
- this._asynchronousDataSourceListeners.removeElement(l);
+ xap.util.ArrayHelper.removeElement(this._asynchronousDataSourceListeners,l);
};
/**
* @protected
@@ -178,8 +179,8 @@
**/
xap.data.datasource.AbstractDataSource.prototype.fireOnDataRetrieveSucess = function () {
/*for (int*/
- for (var i = 0; i < this._asynchronousDataSourceListeners.size(); i++) {
- this._asynchronousDataSourceListeners.elementAt(i).onDataRequestCompleted(this);
+ for (var i = 0; i < this._asynchronousDataSourceListeners.length; i++) {
+ this._asynchronousDataSourceListeners[i].onDataRequestCompleted(this);
}
};
/**
@@ -189,11 +190,32 @@
**/
xap.data.datasource.AbstractDataSource.prototype.fireOnDataRetrieveFailure = function (failureCause) {
/*for (int*/
- for (var i = 0; i < this._asynchronousDataSourceListeners.size(); i++) {
- (this._asynchronousDataSourceListeners.elementAt(i)).onDataRequestFailed(this, failureCause);
+ for (var i = 0; i < this._asynchronousDataSourceListeners.length; i++) {
+ this._asynchronousDataSourceListeners[i].onDataRequestFailed(this, failureCause);
}
};
+//-----------------------------------------------------------------------
+// ContainerLifecycleObject Interface.
+//-----------------------------------------------------------------------
+
+/**
+ * @public
+ * @return {void}
+ **/
+/**
+ * @param container{Container}
+ * @param name{String}
+ **/
+xap.data.datasource.AbstractDataSource.prototype.addedToContainer = function (container, name) {
+ //NOOP
+};
+
+
+/**
+ * @public
+ * @return {void}
+ **/
/**
* @param container{Container}
* @param name{String}
@@ -383,7 +405,7 @@
**/
xap.data.datasource.AbstractDataSource.prototype.addPostponedQuery = function (query, context, listener) {
var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
- this._postponedQueries.addElement(queryRecord);
+ this._postponedQueries.push(queryRecord);
}
/**
* Executes all posponed queries in order they came in.
@@ -395,9 +417,9 @@
**/
xap.data.datasource.AbstractDataSource.prototype.executePostponedQueries = function () {
try {
- for (var i = 0; i < this._postponedQueries.size(); i++) {
+ for (var i = 0; i < this._postponedQueries.length; i++) {
/*QueryRecord*/
- var rec = this._postponedQueries.elementAt(i);
+ var rec = this._postponedQueries[i];
try {
this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
}
@@ -409,7 +431,7 @@
}
}
finally {
- this._postponedQueries.removeAllElements();
+ this.clearPostponedQueries();
}
}
@@ -421,7 +443,7 @@
* @return {void}
**/
xap.data.datasource.AbstractDataSource.prototype.clearPostponedQueries = function () {
- this._postponedQueries = new xap.util.Vector();
+ this._postponedQueries = [];
}
/**
@@ -431,7 +453,7 @@
* @return {Log}
**/
xap.data.datasource.AbstractDataSource.prototype.getLog = function () {
- return xap.log.Logger.getLogger("DataSource");
+ return xap.util.LogFactory.getLog("DataSource");
};
//-----------------------------------------------------------------------
@@ -463,7 +485,7 @@
// changes
if (listener && listener.getBindingType() != xap.data.controller.BindingType.ONE_TIME) {
var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
- this._boundQueries.addElement(queryRecord);
+ this._boundQueries.push(queryRecord);
}
this.handleQuery(query, context, listener);
};
@@ -499,9 +521,9 @@
* @throws DataAccessException, MalformedQueryException
**/
xap.data.datasource.AbstractDataSource.prototype.requeryAll = function () {
- for (var i = 0; i < this._boundQueries.size(); i++) {
+ for (var i = 0; i < this._boundQueries.length; i++) {
/*QueryRecord*/
- var rec = this._boundQueries.elementAt(i);
+ var rec = this._boundQueries[i];
this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
}
Modified: incubator/xap/trunk/codebase/src/xap/data/datasource/DataSetFactory.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/datasource/DataSetFactory.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/datasource/DataSetFactory.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/datasource/DataSetFactory.js Mon Feb 12 17:01:29 2007
@@ -19,7 +19,6 @@
**/
Xap.provide("xap.data.datasource.DataSetFactory");
-Xap.require("xap.util.Vector");
/**
* DataSetFactory maps data object types to the appropriate DataSet instances.
@@ -37,7 +36,6 @@
// instantiate this factor---use single instance kept
// on class
};
-Xap.setupClassAsSubclassOf("xap.data.datasource.DataSetFactory", "Object");
//-----------------------------------------------------------------------
// Class Variables.
@@ -87,20 +85,17 @@
Xap.require("xap.data.datasource.ArrayDataSet") ;
return new xap.data.datasource.ArrayDataSet(query, dataSource, arr);
} else {
+
+ //IMPORTANT in other places we use dojo.isArray? Or is array like?
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/codebase/src/xap/data/datasource/ObjectDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/datasource/ObjectDataSource.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/datasource/ObjectDataSource.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/datasource/ObjectDataSource.js Mon Feb 12 17:01:29 2007
@@ -19,7 +19,6 @@
Xap.provide("xap.data.datasource.ObjectDataSource");
Xap.require("xap.data.datasource.AbstractDataSource");
-Xap.require("xap.util.Vector");
Xap.require("xap.data.datasource.AbstractDataSet") ;
Xap.require("xap.xml.ParserFactory") ;
Xap.require("xap.xml.dom.Document");
Modified: incubator/xap/trunk/codebase/src/xap/data/datasource/SimpleDocumentDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/datasource/SimpleDocumentDataSource.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/datasource/SimpleDocumentDataSource.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/datasource/SimpleDocumentDataSource.js Mon Feb 12 17:01:29 2007
@@ -18,8 +18,7 @@
**/
Xap.provide("xap.data.datasource.SimpleDocumentDataSource");
-Xap.require("xap.data.datasource.AbstractDataSource");
-Xap.require("xap.util.Vector");
+Xap.require("xap.data.datasource.AbstractDataSource");
Xap.require("xap.data.datasource.AbstractDataSet") ;
Xap.require("xap.xml.ParserFactory") ;
Xap.require("xap.xml.dom.Document");
Modified: incubator/xap/trunk/codebase/src/xap/session/ClientSession.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/session/ClientSession.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/session/ClientSession.js (original)
+++ incubator/xap/trunk/codebase/src/xap/session/ClientSession.js Mon Feb 12 17:01:29 2007
@@ -83,6 +83,8 @@
}
+xap.session.ClientSession.s_log = xap.util.LogFactory.getLog( "xap.session.ClientSession" );
+
//-----------------------------------------------------------------------
// Public Methods.
//-----------------------------------------------------------------------
@@ -203,8 +205,7 @@
//TODO watch out for comments, text nodes, etc?
var ns = child.getNamespaceUri();
- if( ns != null &&
- namespaceHandlerManager.isNamespaceRegistered( ns )) {
+ if(ns) {
namespaceHandlerManager.dispatch( child );
}
}
Modified: incubator/xap/trunk/codebase/src/xap/taghandling/AbstractTagImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/taghandling/AbstractTagImpl.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/taghandling/AbstractTagImpl.js (original)
+++ incubator/xap/trunk/codebase/src/xap/taghandling/AbstractTagImpl.js Mon Feb 12 17:01:29 2007
@@ -17,22 +17,14 @@
*
*/
-//Let Dojo know what to expect from this file:
Xap.provide('xap.taghandling.AbstractTagImpl');
-
Xap.require("xap.xml.dom.events.StructureChangeEvent");
Xap.require("xap.xml.dom.events.AttributeChangeEvent");
Xap.require("xap.session.ClientEvent");
Xap.require("google.*");
Xap.require("xap.xml.InvalidXmlException");
-Xap.require("xap.session.EventHandler") ;
-Xap.require("xap.xml.dom.Document") ;
-
-//TODO we need to handle qualifying URLs properly based on the request page again
-//right now if we have onCommand=../blah that is relative to root rather than
-//where page was loaded from
/**
* @fileoverview The base class for all element to peer object
@@ -356,36 +348,6 @@
return this.getSession().getUrlContext();
}
-///**
-// * Turns a potentially relative URL into a fully qualified one.
-// * If this is called from the parsing thread during the parsing of a page,
-// * the url is qualified relative to that page's origin. Otherwise the
-// * url should begin with http:/, https:// or "/"
-// * @param relativeUrl The URL to qualify.
-// * @return A fully qualified URL.
-// * @throws MalformedURLException
-// */
-//xap.taghandling.AbstractTagImpl.prototype.createQualifiedUrl = function( relativeUrl ) {
-// var urlContext = this.getUrlContext();
-// if ( urlContext != null ) {
-// return this.getSession().getRequestService().
-// createFullyQualifiedUrl( urlContext,
-// relativeUrl);
-// }
-// return this.getSession().getRequestService().createFullyQualifiedUrl(relativeUrl);
-//
-//}
-//
-//xap.taghandling.AbstractTagImpl.prototype.createQualifiedUrlAsString = function( relativeUrl ) {
-// var urlContext = this.getUrlContext();
-// if ( urlContext != null ) {
-// return this.getSession().getRequestService().
-// createFullyQualifiedUrlAsString( urlContext, relativeUrl );
-// }
-// return this.getSession().getRequestService().
-// createFullyQualifiedUrlAsString( relativeUrl );
-//}
-
/**
* This method is used to fire an event in a standard manner.
* The ClientEvent encapsulates any extra info in the event. The eventValue
@@ -617,6 +579,8 @@
* @param e The StructureChangeEvent
*/
xap.taghandling.AbstractTagImpl.prototype.beforeChildAdded = function( e ) {
+
+//IMPORTANT need this to work for binding text nodes
//
// if (e.getType() == xap.xml.dom.events.StructureChangeEvent.TEXT_NODE) {
// ResolutionHandler resolverRegistry = getUiContentHandler().getResolverRegistry();
@@ -720,18 +684,6 @@
}
}
-
-//
-//
-// private void writeBackRemoveChild(int index){
-// synchronized(getUiDocument().getDomSynchronizationObject()){
-// getElement().removeStructureChangeListener(this);
-// getElement().removeChildAt(index);
-// getElement().addStructureChangeListener(this);
-// }
-// }
-//}
-
/**
* This method is used to report problems in attribute parsing
* in a standardized manner. Subclasses should call this if they
@@ -787,7 +739,6 @@
// *
// * @return The PluginDocumentHandler.
// *
-// * @since 4.5/jRex1.1
// */
//xap.taghandling.AbstractTagImpl.prototype.getPluginDocumentHandler = function(){
//
@@ -798,7 +749,7 @@
// documentHandler = this.getUiContentHandler();
// }
//
-// //IMPORTANT revisit this!
+// //IMPORTANT revisit this and replace getUiContentHandler with this.
// return documentHandler;
//
//}
Modified: incubator/xap/trunk/codebase/src/xap/util/ArrayHelper.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/util/ArrayHelper.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/util/ArrayHelper.js (original)
+++ incubator/xap/trunk/codebase/src/xap/util/ArrayHelper.js Mon Feb 12 17:01:29 2007
@@ -18,18 +18,15 @@
*/
Xap.provide("xap.util.ArrayHelper");
-//TODO like many classes exception handling here needs to be
-//more thought out.
/**
- * @fileoverview A class that helps add some functionality to arrays.
+ * @fileoverview A class that provides Array utility methods.
*
* @author jmargaris
*/
/**
- * There is no need to ever construct a ArrayHelper object
- * at this time, just use the static methods.
+ * ArrayHelper should never be constructed.
*
* @class ArrayHelper provides methods to implement some common
* functions missing on arrays. (At least in some JS versions)
@@ -43,25 +40,15 @@
/**
- * Removes the first occurence of the given element
- * from the given array.
+ * Inserts an element into the given array at a given index.
*
- * @param {Array} array The array to insert into
+ * @param {Array} array The array to insert into.
* @param element The element to add to the array.
- * @param index The place to add the new element. If left out or less than zero
- * element will be appended to end.
- * @return {Array} The array with the element removed.
+ * @param {int} index The place to add the new element.
+ * @return {Array} The array with the element inserted.
*/
xap.util.ArrayHelper.insertElementAt = function( array, element, index){
- if (!array){
- return null;
- }
- if (index && index>0){
- return array.splice(index,0, element);
- }
- else{
- return array.push(element);
- }
+ return array.splice(index,0, element);
}
/**
* Removes the first occurence of the given element
@@ -72,28 +59,34 @@
* @return {Array} The array with the element removed.
*/
xap.util.ArrayHelper.removeElement = function( array, element){
- if (!array){
- return null;
- }
var i = xap.util.ArrayHelper.indexOf(array, element);
if (i<0){
- return null;
+ return array;
}
return array.splice(i,1);
}
+
+/**
+ * Removes the element at the given index of the array.
+ *
+ * @param {Array} array The array to remove the element from.
+ * @param {int} index The index to remove from.
+ * @return {Array} The array with the element removed.
+ */
+xap.util.ArrayHelper.removeElementAt = function( array, index){
+ return array.splice(index,1);
+}
+
/**
* Returns the first index of the given element in the
* given array.
*
* @param {Array} array The array to look in.
* @param element The element to look for.
- * @return {Integer} The index of the element, or -1 if not found.
+ * @return {int} The index of the element, or -1 if not found.
*/
xap.util.ArrayHelper.indexOf = function( array, element){
- if (!array){
- return -1;
- }
for (var i =0; i<array.length; i++){
if (array[i]==element){
return i;
@@ -102,19 +95,41 @@
return -1;
}
+/**
+ * Returns true if the array contains the given element
+ *
+ * @param {Array} array The array to look in.
+ * @param element The element to look for.
+ * @return {boolean} True if the element is in the array.
+ */
+xap.util.ArrayHelper.contains = function( array, element){
+ return xap.util.ArrayHelper.indexOf(array,element)>=0;
+}
+
+/**
+ * Returns a copy of the array.
+ *
+ * @param {Array} array The array to duplicate.
+ * @return {Array} A copy of the array.
+ */
+xap.util.ArrayHelper.clone = function( array ){
+ var newArray = new Array(array.length);
+ for (var i =0; i<array.length; i++){
+ newArray[i] = array[i];
+ }
+ return newArray;
+}
+
/**
* Adds all the contents of an array to the original array.
*
* @param {Array} array The array to which to add.
* @param {Array} newElements An array .
- * @return {Array} The altered array, so we can chain this.
+ * @return {Array} The array with new elements added.
*/
xap.util.ArrayHelper.pushAll = function( array, newElements){
- if (!array || !newElements || !newElements.length){
- return array;
- }
- for (var i =0; i<newElements.length; ++i){
+ for (var i =0; i<newElements.length; i++){
array.push( newElements[i] ) ;
}
return array ;
Modified: incubator/xap/trunk/codebase/src/xap/util/XmlUtils.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/util/XmlUtils.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/util/XmlUtils.js (original)
+++ incubator/xap/trunk/codebase/src/xap/util/XmlUtils.js Mon Feb 12 17:01:29 2007
@@ -33,21 +33,6 @@
xap.util.XmlUtils = function(){}
-// We need to special-case validating tag names to include this
-xap.util.XmlUtils.INDENTATION = " ";
-
-/**
- * Provides an indentation String for the given level of indentation.
- *
- * @param indentationLevel The level of indentation.
- */
-xap.util.XmlUtils.getIndentation = function( indentationLevel ) {
- var indentation = "";
- for ( var i = 0; i < indentationLevel; i++ ) {
- indentation += xap.util.XmlUtils.INDENTATION;
- }
- return indentation;
-}
/**
* This method will XML-encode a string.
@@ -152,42 +137,5 @@
}
}
return buffer.join("");
-}
-
-/**
- * Checks to make sure a given string is a valud XML-1.0 tag name.
- *
- * @param tagName - the string to check
- * @return - true if valid, false otherwise
- */
-xap.util.XmlUtils.isValidXmlTagName = function( tagName ) {
- if( tagName == null ) {
- return false;
- }
- if( tagName.length == 0 ) {
- return false;
- }
- var firstChar = tagName.charAt( 0 );
- if( xap.util.Character.isLetter( firstChar ) == false && firstChar != '_'){
- //tags can begin with only letters or underscore
- return false;
- }
- if( tagName.length >= 3 ) {
- var test = tagName.substring( 0, 3 );
- if( test.toLowerCase() == "xml" ) {
- // Tags cannot start with any variation of "xml"
- return false;
- }
- }
- for( var i = 1; i < tagName.length; i++ ) {
- var c = tagName.charAt( i );
- if( xap.util.Character.isLetterOrDigit(c) == false &&
- c != '.' &&
- c != '_' &&
- c != '-') {
- return false;
- }
- }
- return true;
}
Modified: incubator/xap/trunk/codebase/src/xap/widgets/Label.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/Label.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/Label.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/Label.js Mon Feb 12 17:01:29 2007
@@ -25,8 +25,6 @@
Xap.provide("xap.widgets.Label");
-Xap.require("xap.xml.XmlTokens") ;
-
xap.widgets.Label = function() {
// create label structure
this.table = document.createElement("table");
@@ -34,7 +32,7 @@
this.table.cellPadding = "0px";
this.table.cellSpacing = "0px";
this.td = document.createElement("td");
- this.td.style.textAlign=xap.xml.XmlTokens.LEFT ;
+ this.td.style.textAlign='left' ;
this.td.style.width="100%";
this.td.style.height="100%";
this.br = document.createElement("br");
@@ -58,7 +56,7 @@
this.span.style.verticalAlign="middle";
this.img = document.createElement("img");
this.img.style.verticalAlign="middle";
- this.img.style.display = xap.xml.XmlTokens.NONE ;
+ this.img.style.display = 'none' ;
this.div.appendChild(this.img);
this.div.appendChild(this.span);
@@ -71,13 +69,13 @@
this.text = "";
this.imgURL = "";
this.imgDisabledURL = "";
- this.richText = xap.xml.XmlTokens.FALSE ;
+ this.richText = 'false' ;
this.textPlacementVertical = "";
this.textPlacementHorizontal = "";
- this.setSelectable(xap.xml.XmlTokens.FALSE);
- this.setEnabled(xap.xml.XmlTokens.TRUE);
- this.setAutoWrap(xap.xml.XmlTokens.FALSE);
+ this.setSelectable('false');
+ this.setEnabled('true');
+ this.setAutoWrap('false');
}
xap.widgets.Label.prototype._createHintImg = function(){
@@ -126,7 +124,7 @@
*/
xap.widgets.Label.prototype._showText = function() {
// give it proper text placement
- if (this.img.style.display != xap.xml.XmlTokens.NONE) {
+ if (this.img.style.display != 'none') {
if (this.textPlacementHorizontal == "left" || this.textPlacementHorizontal == "right") {
var children = this.div.childNodes;
@@ -155,7 +153,7 @@
this.span.innerHTML = "";
- if (this.richText == xap.xml.XmlTokens.TRUE) {
+ if (this.richText == 'true') {
this.span.innerHTML = this.text;
} else {
this.span.appendChild(document.createTextNode(this.text));
@@ -219,7 +217,7 @@
* @param {boolean} autoWrap if true, the text will be wrapped when necessary, otherwise, no wrap.
*/
xap.widgets.Label.prototype.setAutoWrap = function(autoWrap) {
- if (autoWrap == xap.xml.XmlTokens.TRUE) {
+ if (autoWrap == 'true') {
xap.widgets.styleSet(this.td, {whiteSpace: "normal"});
} else {
xap.widgets.styleSet(this.td, {whiteSpace: "nowrap"});
@@ -239,7 +237,7 @@
* @param {int} imgHeight the height of the img.
*/
xap.widgets.Label.prototype.setImgHeight = function(imgHeight) {
- this.img.setAttribute(xap.xml.XmlTokens.HEIGHT,imgHeight);
+ this.img.setAttribute('height',imgHeight);
}
/**
@@ -247,7 +245,7 @@
* @param {int} imgWidth the width.
*/
xap.widgets.Label.prototype.setImgWidth = function(imgWidth) {
- this.img.setAttribute(xap.xml.XmlTokens.WIDTH,imgWidth);
+ this.img.setAttribute('width',imgWidth);
}
var a = 0;
@@ -256,7 +254,7 @@
* @param {boolean} seletable if true, user can select the label, otherwise user cannot.
*/
xap.widgets.Label.prototype.setSelectable = function(selectable) {
- if (selectable == xap.xml.XmlTokens.TRUE) {
+ if (selectable == 'true') {
this.td.onmousedown = null;
this.td.onselectstart = null;
} else {
@@ -270,7 +268,7 @@
* @param {boolean} enabled if true the label is enabled, otherwise it is disabled.
*/
xap.widgets.Label.prototype.setEnabled = function(enabled) {
- this.enabled = (enabled == xap.xml.XmlTokens.TRUE) ;
+ this.enabled = (enabled == 'true') ;
this._showImg();
}
@@ -287,7 +285,7 @@
this._showText();
} else {
- this.img.style.display = xap.xml.XmlTokens.NONE;
+ this.img.style.display = 'none';
}
}
}
Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/ComboBoxTextField.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/ComboBoxTextField.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/ComboBoxTextField.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/ComboBoxTextField.js Mon Feb 12 17:01:29 2007
@@ -226,7 +226,7 @@
// A textfield's 'value' is its displayed text:
this.textField.value = selectedOption.text ;
- this.writeBackAttribute(xap.xml.XmlTokens.VALUE,selectedOption.text) ;
+ this.writeBackAttribute('value',selectedOption.text) ;
}
Modified: incubator/xap/trunk/codebase/src/xap/xml/NamespaceHandlerManager.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/NamespaceHandlerManager.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/NamespaceHandlerManager.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/NamespaceHandlerManager.js Mon Feb 12 17:01:29 2007
@@ -21,7 +21,6 @@
Xap.require("xap.xml.sax.ParserException");
-
Xap.require("xap.util.Hashtable");
Xap.require("xap.util.Exception");
@@ -63,36 +62,26 @@
// Public Methods.
//-----------------------------------------------------------------------
xap.xml.NamespaceHandlerManager.prototype.dispatch = function( element ) {
- if( ! this.isNamespaceRegistered( element.getNamespaceUri() )) {
- // TODO - internationalize
+
+ var handler = this._namespaceToHandlersMap.get(element.getNamespaceUri() );
+ if (!handler){
+ // TODO - internationalize
throw new xap.util.Exception( "The namespace supplied [" +
element.getNamespaceUri() + "] is not valid." );
}
- var handler = this._namespaceToHandlersMap.get(
- element.getNamespaceUri() );
try {
handler.receiveDispatch( element );
} catch ( e ) {
+
+ //IMPORTANT CLEAN UP THIS ERROR HANDLING
if (xap.xml.NamespaceHandlerManager.s_log.isTrace()){
xap.xml.NamespaceHandlerManager.s_log.trace( "xap.xml.NamespaceHandler.dispatch:" + e );
}
throw new xap.xml.sax.ParserException(
xap.xml.sax.ParserException.NAMESPACE_HANDLER_FAILURE,
new Array( handler + " " + element.getNamespaceUri(), "-1", "-1" ),
- e );
- }
+ e ); }
}
-
-/**
- * Returns true if the namespace supplied is valid, false otherwise.
- *
- * @param ns the namespace to be checked.
- * @return true if the namespace supplied is valid, false otherwise.
- */
-xap.xml.NamespaceHandlerManager.prototype.isNamespaceRegistered = function( ns ) {
- return ( this._namespaceToHandlersMap.get( ns ) != null );
-}
-
xap.xml.NamespaceHandlerManager.prototype.addHandler = function( namespace, handler ) {
this._namespaceToHandlersMap.put( namespace, handler);
Modified: incubator/xap/trunk/codebase/src/xap/xml/dom/Document.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/dom/Document.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/dom/Document.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/dom/Document.js Mon Feb 12 17:01:29 2007
@@ -84,19 +84,6 @@
/** @private */
xap.xml.dom.Document.XML_DECL_WITHOUT_ENC = "<?xml version=\"1.0\"?>";
-/** @private */
-xap.xml.dom.Document.BEFORE_ADD = 0;
-
-/** @private */
-xap.xml.dom.Document.BEFORE_REMOVE = 1;
-
-/** @private */
-xap.xml.dom.Document.ON_ADD = 2;
-
-/** @private */
-xap.xml.dom.Document.ON_REMOVE = 3;
-
-
//-----------------------------------------------------------------------
// xap.xml.dom.Document Interface.
//-----------------------------------------------------------------------
@@ -200,7 +187,7 @@
this._notifyListenersOfStructureChange
- ( this._structureChangeListeners, event, xap.xml.dom.Document.BEFORE_ADD );
+ ( this._structureChangeListeners, event, 'beforeChildAdded' );
// Take the element from the event because they have the
@@ -230,7 +217,7 @@
this._addDocumentFragmentToIdMapAndCheckForPrefixCollisions( this._rootElement );
this._notifyListenersOfStructureChange(
- this._structureChangeListeners, event, xap.xml.dom.Document.ON_ADD );
+ this._structureChangeListeners, event, 'onChildAdded');
} else {
@@ -311,13 +298,13 @@
var event = new xap.xml.dom.events.StructureChangeEvent( null, this._rootElement );
this._notifyListenersOfStructureChange
- ( this._structureChangeListeners, event, xap.xml.dom.Document.BEFORE_REMOVE );
+ ( this._structureChangeListeners, 'beforeChildRemoved' );
this.removeChild(this._rootElement);
this._removeDocumentFragmentFromIdMap( this._rootElement );
this._notifyListenersOfStructureChange
- ( this._structureChangeListeners, event, xap.xml.dom.Document.ON_REMOVE );
+ ( this._structureChangeListeners, event, 'onChildRemoved' );
}
}
@@ -325,29 +312,22 @@
/**
* @private
*/
-xap.xml.dom.Document.prototype._notifyListenersOfStructureChange = function( v, e, type ) {
+xap.xml.dom.Document.prototype._notifyListenersOfStructureChange = function( v, e, method ) {
if ( v ) {
for ( var i = 0; i < v.length; i ++ ) {
var listener = v[i];
- switch ( type ) {
- case this.BEFORE_ADD:
- listener.beforeChildAdded( e );
- break;
- case this.ON_ADD:
- listener.onChildAdded( e );
- break;
- case this.BEFORE_REMOVE:
- listener.beforeChildRemoved( e );
- break;
- case this.ON_REMOVE:
- listener.onChildRemoved( e );
- break;
- }
- // Handle the case where the event causes the
- // listener to remove itself.
- if ( v[i] != listener ) {
- i = i - 1;
- }
+
+ //if the listener has that callback method, call it.
+ if (listener[method]){
+ listener[method].call(listener,e);
+
+ // Handle the case where the event causes the
+ // listener to remove itself.
+ if ( v[i] != listener ) {
+ i = i - 1;
+ }
+ }
+
}
}
}
Modified: incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js Mon Feb 12 17:01:29 2007
@@ -71,7 +71,7 @@
this.setAttribute( "id", id );
}
else{
- this.setAttribute( "id",xap.xml.dom.XapElement._createUniqueElementId() );
+ this.setAttribute( "id",xap.util.UidProvider.createId() );
}
}
@@ -89,58 +89,15 @@
/** @private */
xap.xml.dom.XapElement.CANNOT_SET_ID_ATTRIBUTE_WHEN_PART_OF_DOCUMENT = "cannotSetIdAttributeWhenPartOfOwnerDocument";
-// {0} - The length of the array.
-// {1} - The specified index of the key value pair.
-/** @private */
-xap.xml.dom.XapElement.CANT_REMOVE_KEY_VALUE_PAIR_FROM_ARRAY = "cantRemoveKeyValuePair";
-
-// No-args
/** @private */
xap.xml.dom.XapElement.DOC_OWNERSHIP_FAILURE = "docOwnershipNotificationFailure";
-
/** @private */
xap.xml.dom.XapElement.CLASSNAME = "xap.xml.dom.XapElement";
/** @private */
-xap.xml.dom.XapElement.INITIAL_ATTRIBUTES_ARRAY_SIZE = 4 * 2;
-
-/** @private */
-xap.xml.dom.XapElement.INITIAL_LISTENER_ARRAY_SIZE = 2 * 2;
-
-/** @private */
xap.xml.dom.XapElement.INDENT = " ";
-xap.xml.dom.XapElement.BEFORE_ATTRIBUTE_REMOVED = "beforeAttributeRemoved";
-xap.xml.dom.XapElement.ON_ATTRIBUTE_REMOVED = "onAttributeRemoved";
-xap.xml.dom.XapElement.BEFORE_ATTRIBUTE_SET = "beforeAttributeSet";
-xap.xml.dom.XapElement.ON_ATTRIBUTE_SET = "onAttributeSet";
-xap.xml.dom.XapElement.BEFORE_CHILD_REMOVED = "beforeChildRemoved";
-xap.xml.dom.XapElement.BEFORE_CHILD_ADDED = "beforeChildAdded";
-xap.xml.dom.XapElement.ON_CHILD_REMOVED= "onChildRemoved";
-xap.xml.dom.XapElement.ON_CHILD_ADDED= "onChildAdded";
-
-
-
-/**
- * Passed to the private method _toStringHelper(), this means that when
- * encoding attributes, only double quotes will be encoded.
- * @private
- */
-xap.xml.dom.XapElement.ENCODE_ONLY_DOUBLE_QUOTES_IN_ATTRIBUTES = 0;
-/**
- * Passed to the private method _toStringHelper(), this means that when
- * encoding attributes, everything will be encoded except single ticks.
- * @private
- */
-xap.xml.dom.XapElement.ENCODE_EVERYTHING_BUT_SINGLE_TICKS_IN_ATTRIBUTES = 1;
-/**
- * Passed to the private method _toStringHelper(), this means that when
- * encoding attributes, everything will be encoded.
- * @private
- */
-xap.xml.dom.XapElement.ENCODE_EVERYTHING_IN_ATTRIBUTES = 2;
-
/** @private */
xap.xml.dom.XapElement.s_log = xap.log.Logger.getLogger( "xap.xml.dom.DocumentObjectModel" );
@@ -162,15 +119,6 @@
// Private Class Methods.
//-----------------------------------------------------------------------
-/**
- * Creates a unique i.d., using a provider class.
- * @return a unique i.d.
- * @private
-**/
-xap.xml.dom.XapElement._createUniqueElementId = function() {
- return xap.util.UidProvider.createId();
-}
-
/** Appends this class' indentation string to a prexisting string:
* @param{int} indent The indentation level.
@@ -244,7 +192,7 @@
this._doAnyAttributeChangeListenersExist( doc );
if ( attributeChangeListenersExist ) {
event = new xap.xml.dom.events.AttributeChangeEvent( this, name, value );
- this._fireAttributeChangeEvent( doc, event, xap.xml.dom.XapElement.BEFORE_ATTRIBUTE_SET);
+ this._fireAttributeChangeEvent( doc, event, 'beforeAttributeSet');
// Listeners have the opportunity to modify the value.
// Make sure we get the latest value out of the event.
value = event.getNewValue();
@@ -262,7 +210,7 @@
google.XNode.prototype.setAttribute.call(this, name, value, baseUrl);
if ( attributeChangeListenersExist ) {
- this._fireAttributeChangeEvent( doc, event, xap.xml.dom.XapElement.ON_ATTRIBUTE_SET);
+ this._fireAttributeChangeEvent( doc, event, 'onAttributeSet');
}
}
@@ -278,11 +226,11 @@
var event = new xap.xml.dom.events.AttributeChangeEvent(this, name, null);
- this._fireAttributeChangeEvent( doc, event, xap.xml.dom.XapElement.BEFORE_ATTRIBUTE_REMOVED);
+ this._fireAttributeChangeEvent( doc, event, 'beforeAttributeRemoved');
// Actually perform the removal:
google.XNode.prototype.removeAttribute.call(this, name);
- this._fireAttributeChangeEvent( doc, event, xap.xml.dom.XapElement.ON_ATTRIBUTE_REMOVED);
+ this._fireAttributeChangeEvent( doc, event, 'onAttributeRemoved');
// We never allow elements not to have IDs - if the id attribute tries
// to be removed - remove it then reset it with one of our IDs
@@ -291,7 +239,7 @@
//the document type or something like that? Maybe when we add to a doc
//that expects IDs we should assign them then instead of here?
if ( "id" == name ) {
- setAttribute( "id", xap.xml.dom.XapElement._createUniqueElementId());
+ setAttribute( "id", xap.util.UidProvider.createId());
}
return name;
@@ -377,7 +325,7 @@
//notify listeners before the change takes place
if ( structureChangeListenerExists ) {
event = new xap.xml.dom.events.StructureChangeEvent(this, child, index);
- this._fireStructureChangeEvent( doc, event, xap.xml.dom.XapElement.BEFORE_CHILD_REMOVED);
+ this._fireStructureChangeEvent( doc, event, 'beforeChildRemoved');
}
//make the actual change
@@ -393,7 +341,7 @@
//notify listeners on attribute change
if ( structureChangeListenerExists ) {
- this._fireStructureChangeEvent( doc, event, xap.xml.dom.XapElement.ON_CHILD_REMOVED);
+ this._fireStructureChangeEvent( doc, event, 'onChildRemoved');
}
//TODO child here could be changed by the before event?
@@ -447,8 +395,7 @@
sbuf,
0,
prettyPrint,
- true,
- xap.xml.dom.XapElement.ENCODE_EVERYTHING_IN_ATTRIBUTES );
+ true );
return sbuf;
}
@@ -464,51 +411,10 @@
sbuf,
0,
prettyPrint,
- false,
- xap.xml.dom.XapElement.ENCODE_EVERYTHING_IN_ATTRIBUTES );
+ false );
return sbuf;
}
-/**
- * Returns an XML string representing this element
- * and all children where only quotes inside of attribute values are
- * encoded. Less than, greater than, apostrophe and ampersand are all
- * left unencoded when inside of attribute values.
- *
- * @param prettyPrint If true print this in human-readable form with spacing.
- */
-xap.xml.dom.XapElement.prototype.toXmlWithSimpleAttributeEncoding = function( prettyPrint ) {
- var sbuf = "";
- sbuf = this._toStringHelper( this,
- sbuf,
- 0,
- prettyPrint,
- true,
- xap.xml.dom.XapElement.ENCODE_ONLY_DOUBLE_QUOTES_IN_ATTRIBUTES );
- return sbuf;
-}
-/**
- * Returns an XML string representing this element
- * and all children without any auto-generated IDs
- * where only quotes inside of attribute values are
- * encoded. Less than, greater than, apostrophe and ampersand are all
- * left unencoded when inside of attribute values.
- *
- * @param prettyPrint If true print this in human-readable form with spacing.
- */
-xap.xml.dom.XapElement.prototype.toXmlWithSimpleAttributeEncodingWithoutAutoAssignedIds =
- function ( prettyPrint ) {
- var sbuf = "";
- sbuf = this._toStringHelper( this,
- sbuf,
- 0,
- prettyPrint,
- false,
- xap.xml.dom.XapElement.ENCODE_ONLY_DOUBLE_QUOTES_IN_ATTRIBUTES );
- return sbuf;
-}
-
-/////////////////////////
/**
* Adds an xap.xml.dom.events.AttributeChangeListener to the element. This listener
@@ -630,7 +536,7 @@
if ( structureChangeListenersExist ) {
event = new xap.xml.dom.events.StructureChangeEvent( this, newNode, index );
- this._fireStructureChangeEvent( doc, event, xap.xml.dom.XapElement.BEFORE_CHILD_ADDED);
+ this._fireStructureChangeEvent( doc, event, 'beforeChildAdded');
// The listeners have the opportunity to modify what is getting
// added, so make sure that what we add is the subtree on the
// event, not the element passed to this method.
@@ -680,7 +586,7 @@
}
if ( structureChangeListenersExist ) {
- this._fireStructureChangeEvent( doc, event, xap.xml.dom.XapElement.ON_CHILD_ADDED);
+ this._fireStructureChangeEvent( doc, event, 'onChildAdded');
}
return newNode;
}
@@ -785,8 +691,7 @@
* class.
*/
xap.xml.dom.XapElement.prototype._toStringHelper = function( node, sbuf, indent, prettyPrint,
- withInternalIds,
- attributeEncodingChoice ) {
+ withInternalIds) {
if( node.nodeType == google.DOM_TEXT_NODE ) {
// if its a string, simply print it XML-encoded
sbuf += xap.util.XmlUtils.encode( node.nodeValue );
@@ -862,22 +767,8 @@
continue;
}
}
-
sbuf += ' ' + key + "=\"";
- switch ( attributeEncodingChoice ) {
- case xap.xml.dom.XapElement.ENCODE_ONLY_DOUBLE_QUOTES_IN_ATTRIBUTES:
- sbuf += xap.util.XmlUtils.encodeDoubleQuotes( value );
- break;
- case xap.xml.dom.XapElement.ENCODE_EVERYTHING_BUT_SINGLE_TICKS_IN_ATTRIBUTES:
- // NOTE: This is not on xap.util.XmlUtils because that's a public
- // class.
- sbuf += this._encodeEverythingButSingleTicks( value );
- break;
- case xap.xml.dom.XapElement.ENCODE_EVERYTHING_IN_ATTRIBUTES:
- // Fallthrough to the default.
- default:
- sbuf += xap.util.XmlUtils.encode( value );
- }
+ sbuf += xap.util.XmlUtils.encode( value );
sbuf += '\"';
}
@@ -897,8 +788,7 @@
sbuf,
indent + 1,
prettyPrint,
- withInternalIds,
- attributeEncodingChoice);
+ withInternalIds);
}
if( prettyPrint && elementHasTextNode == false ) {
@@ -960,14 +850,13 @@
for (var i =0; i<listeners.length; i++){
var listener = listeners[i];
- //TODO check for existence?
if(listener[methodName]){
listener[methodName].call(listener, event);
- }
-
- if ( listeners[i] != listener ) {
+
+ if ( listeners[i] != listener ) {
i = i - 1;
- }
+ }
+ }
}
}
@@ -1065,7 +954,7 @@
//if the id was generated replace it with a new generated one
if ( xap.xml.dom.XapElement.isGeneratedId( id ) ) {
- e.setAttribute( "id", xap.xml.dom.XapElement._createUniqueElementId());
+ e.setAttribute( "id", xap.util.UidProvider.createId());
}
Modified: incubator/xap/trunk/codebase/src/xap/xml/dom/XapElementRes.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/dom/XapElementRes.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/dom/XapElementRes.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/dom/XapElementRes.js Mon Feb 12 17:01:29 2007
@@ -30,6 +30,5 @@
xap.xml.dom.XapElementRes = function() {
this.messages = new Object();
this.messages[xap.xml.dom.XapElement.CANNOT_SET_ID_ATTRIBUTE_WHEN_PART_OF_DOCUMENT] = "This element is part of a document. The \"id\" attribute cannot be set on an element after it has been added to a document.";
- this.messages[xap.xml.dom.XapElement.CANT_REMOVE_KEY_VALUE_PAIR_FROM_ARRAY] = "Can''t remove key/value pair from an array of size {0} where the key index is specified as {1}.";
this.messages[xap.xml.dom.XapElement.DOC_OWNERSHIP_FAILURE] = "There was an error notifying a xap.xml.dom.DocumentOwnershipListener, continuing gracefully.";
}
Modified: incubator/xap/trunk/codebase/src/xap/xml/sax/SaxParser.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/sax/SaxParser.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/sax/SaxParser.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/sax/SaxParser.js Mon Feb 12 17:01:29 2007
@@ -20,21 +20,10 @@
//Let Dojo know what to expect from this file:
Xap.provide("xap.xml.sax.SaxParser");
-// Auto-added---o.k.?
-Xap.require("xap.xml.sax.ParserException");
-
-// Auto-added---o.k.?
-Xap.require("xap.xml.sax.EmptyDocumentException");
-// Auto-added---o.k.?
+Xap.require("xap.xml.sax.ParserException");
Xap.require("xap.util.Hashtable");
-
-// Auto-added---o.k.?
Xap.require("xap.util.Character");
-
-Xap.require("xap.xml.sax.SaxContentHandler") ;
-
-Xap.require("xap.util.*");
/**
Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js Mon Feb 12 17:01:29 2007
@@ -24,7 +24,6 @@
AttributeTester = function(){
this._log = xap.log.Logger.getLogger("AttributeTester");
this._log.setLevel(xap.log.Logger.TRACE);
-
AttributeTesterObj = this;
this._registeredElements = [];
}
Modified: incubator/xap/trunk/unittests/testsrc/xap/util/_TestXmlUtils.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/util/_TestXmlUtils.html?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/util/_TestXmlUtils.html (original)
+++ incubator/xap/trunk/unittests/testsrc/xap/util/_TestXmlUtils.html Mon Feb 12 17:01:29 2007
@@ -41,12 +41,9 @@
Xap.require("xap.util.XmlUtils");
function testXmlUtilsMethods() {
- assertTrue( xap.util.XmlUtils.getIndentation != null );
assertTrue( xap.util.XmlUtils.encode != null );
assertTrue( xap.util.XmlUtils.decode != null );
- assertTrue( xap.util.XmlUtils.getIndentation != null );
assertTrue( xap.util.XmlUtils.encodeDoubleQuotes != null );
- assertTrue( xap.util.XmlUtils.isValidXmlTagName != null );
}
function testEncode() {
@@ -57,12 +54,7 @@
function testDecode() {
var decoded = xap.util.XmlUtils.decode( "<foo>" );
assertEquals( decoded, "<foo>" );
- }
-
- function testIsValidXmlTagName() {
- var result = xap.util.XmlUtils.isValidXmlTagName("foo");
- assertTrue( result );
- }
+ }
</script>
</body>
Modified: incubator/xap/trunk/unittests/testsrc/xap/xml/_TestElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/unittests/testsrc/xap/xml/_TestElement.js?view=diff&rev=506785&r1=506784&r2=506785
==============================================================================
--- incubator/xap/trunk/unittests/testsrc/xap/xml/_TestElement.js (original)
+++ incubator/xap/trunk/unittests/testsrc/xap/xml/_TestElement.js Mon Feb 12 17:01:29 2007
@@ -42,7 +42,6 @@
function testElementMethods() {
var doc = new xap.xml.dom.Document( null );
var el = doc.createElement( "bar" );
- assertTrue( "xap.xml.dom.XapElement._createUniqueElementId", xap.xml.dom.XapElement._createUniqueElementId != null );
assertTrue( "xap.xml.dom.XapElement.isGeneratedId", xap.xml.dom.XapElement.isGeneratedId != null );
assertTrue( "el.addAttributeChangeListener", el.addAttributeChangeListener != null );
assertTrue( "el.addDocumentOwnershipListener", el.addDocumentOwnershipListener != null );
@@ -66,8 +65,6 @@
assertTrue( "el.toString", el.toString != null );
assertTrue( "el.toXml", el.toXml != null );
assertTrue( "el.toXmlWithoutAutoAssignedIds", el.toXmlWithoutAutoAssignedIds != null );
- assertTrue( "el.toXmlWithSimpleAttributeEncoding", el.toXmlWithSimpleAttributeEncoding != null );
- assertTrue( "el.toXmlWithSimpleAttributeEncodingWithoutAutoAssignedIds", el.toXmlWithSimpleAttributeEncodingWithoutAutoAssignedIds != null );
}