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/09/25 02:45:29 UTC
svn commit: r449550 [1/2] - in /incubator/xap/trunk/src/xap/data: ./ bridge/
controller/ datasource/ events/
Author: mturyn
Date: Sun Sep 24 19:45:28 2006
New Revision: 449550
URL: http://svn.apache.org/viewvc?view=rev&rev=449550
Log:
Basic binding works for JavascriptDataSource and its bridge class when DeclarativeArgumentParser is updated---won't do that last until I can find out what's breaking its unit test.
Added:
incubator/xap/trunk/src/xap/data/XmlDataTokens.js
incubator/xap/trunk/src/xap/data/controller/BindingContainerImpl.js
Modified:
incubator/xap/trunk/src/xap/data/DataFramework.js
incubator/xap/trunk/src/xap/data/DataServiceFactory.js
incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js
incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js
incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js
incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js
incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js
incubator/xap/trunk/src/xap/data/controller/Binding.js
incubator/xap/trunk/src/xap/data/controller/BindingType.js
incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js
incubator/xap/trunk/src/xap/data/datasource/DataSourceContainerImpl.js
incubator/xap/trunk/src/xap/data/datasource/DataSourceImpl.js
incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js
incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js
incubator/xap/trunk/src/xap/data/datasource/QueryRecord.js
incubator/xap/trunk/src/xap/data/events/ObjectLoadRequestListener.js
Modified: incubator/xap/trunk/src/xap/data/DataFramework.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/DataFramework.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/DataFramework.js (original)
+++ incubator/xap/trunk/src/xap/data/DataFramework.js Sun Sep 24 19:45:28 2006
@@ -19,23 +19,23 @@
Xap.require("xap.session.ClientSession");
//Xap.require("xap.mco.AbstractMco") ;
Xap.require("xap.mco.ContainerLifeCycleObject");
-//Xap.require("xap.mco.McoArgumentParser");
+Xap.require("xap.session.DeclarativeArgumentParser");
//Xap.require("xap.resolver.ResolutionInfo") ;
-// Xap.require("xap.plugin.data.controller.Binding") ;
-// Xap.require("xap.plugin.data.controller.BindingContainer") ;
-// Xap.require("xap.plugin.data.controller.BindingContainerImpl") ;
-// Xap.require("xap.plugin.data.controller.BindingResolver") ;
-// Xap.require("xap.plugin.data.controller.BindingType") ;
-// Xap.require("xap.plugin.data.controller.DataControllerException") ;
-// Xap.require("xap.plugin.data.controller.IteratorContainer") ;
-// Xap.require("xap.plugin.data.controller.IteratorContainerImpl") ;
-// Xap.require("xap.plugin.data.datasource.DataAccessException") ;
-// Xap.require("xap.plugin.data.datasource.DataSourceContainer") ;
-// Xap.require("xap.plugin.data.datasource.DataSourceContainerImpl") ;
-// Xap.require("xap.plugin.data.datasource.MalformedQueryException") ;
-// Xap.require("xap.plugin.data.datasource.UnsupportedBindingTypeException") ;
-// Xap.require("xap.plugin.data.formatter.FormatterContainer") ;
-// Xap.require("xap.plugin.data.formatter.FormatterContainerImpl") ;
+Xap.require("xap.data.controller.Binding") ;
+
+Xap.require("xap.data.controller.BindingContainerImpl") ;
+// Xap.require("xap.data.controller.BindingResolver") ;
+Xap.require("xap.data.controller.BindingType") ;
+// Xap.require("xap.data.controller.DataControllerException") ;
+// Xap.require("xap.data.controller.IteratorContainer") ;
+// Xap.require("xap.data.controller.IteratorContainerImpl") ;
+// Xap.require("xap.data.datasource.DataAccessException") ;
+// Xap.require("xap.data.datasource.DataSourceContainer") ;
+Xap.require("xap.data.datasource.DataSourceContainerImpl") ;
+// Xap.require("xap.data.datasource.MalformedQueryException") ;
+// Xap.require("xap.data.datasource.UnsupportedBindingTypeException") ;
+// Xap.require("xap.data.formatter.FormatterContainer") ;
+// Xap.require("xap.data.formatter.FormatterContainerImpl") ;
// Xap.require("xap.util.EscapeSyntaxException") ;
/**
* This class encapsulates all the data primitives available for a client session.
@@ -54,10 +54,9 @@
// alert("created data framework") ;
this._session = sess;
this._dataSourceContainer = new xap.data.datasource.DataSourceContainerImpl(sess);
+ this._bindingContainer = new xap.data.controller.BindingContainerImpl(sess);
// TODO: use the appropriate containers---just
-// placeholders here to avoid follow-on errors.
- this._bindingContainer = new xap.data.datasource.DataSourceContainerImpl(sess);
- //new BindingContainerImpl(sess);
+// placeholders here to avoid follow-on errors.
this._formatterContainer = new xap.data.datasource.DataSourceContainerImpl(sess);
// new FormatterContainerImpl(sess);
this._iteratorContainer = new xap.data.datasource.DataSourceContainerImpl(sess);
@@ -88,11 +87,11 @@
*
* @return The data service.
*/
-/*public DataService*/
+/*public DataServiceImpl*/
xap.data.DataFramework.getDataService = function (sess) {
/*DataFramework*/
var dataService = /*(DataFramework)*/
- sess.getSystemContainer().get(xap.data.DataFramework.MCO_ID);
+ sess.getSystemContainer().get(xap.data.DataFramework.MCO_ID);
if (!dataService) {
dataService = new xap.data.DataFramework(sess);
sess.getSystemContainer().put(xap.data.DataFramework.MCO_ID, dataService);
@@ -103,8 +102,8 @@
// add shortcuts to the binding methods.
// ...so we can do the following:
- //mcoParser.addFunctionShortcut("*", xap.data.DataFramework.MCO_ID + ".relativeBind");
- //mcoParser.addFunctionShortcut("bind", xap.data.DataFramework.MCO_ID + ".bind");
+ mcoParser.addFunctionShortcut("*", xap.data.DataFramework.MCO_ID + ".relativeBind");
+ mcoParser.addFunctionShortcut("bind", xap.data.DataFramework.MCO_ID + ".bind");
}
return dataService;
};
@@ -116,7 +115,7 @@
*/
/*public BindingResolver*/
xap.data.DataFramework.prototype.getBindingResolver = function () {
- return _bindingResolver;
+ return this._bindingResolver;
};
/**
* Set the binding resolver for the data service. INTERNAL
@@ -136,7 +135,7 @@
*/
/*public BindingContainer*/
xap.data.DataFramework.prototype.getBindingContainer = function () {
- return _bindingContainer;
+ return this._bindingContainer;
};
@@ -148,7 +147,7 @@
*/
/*public IteratorContainer*/
xap.data.DataFramework.prototype.getIteratorContainer = function () {
- return _iteratorContainer;
+ return this._iteratorContainer;
};
@@ -172,7 +171,7 @@
}
/* Binding */
var binding = new Binding(this._bindingResolver.getContextStack(), select, bindString, this._session, BindingType.ONE_TIME, null);
- return bind(binding);
+ return this.bind(binding);
};
@@ -274,7 +273,30 @@
// Implementor of DataService interface: xap.data.DataFramework.prototype.bind = function (bindingOrString) {
xap.data.DataFramework.prototype.bind = function (bindingOrString) {
// Need to handle string or binding cases...subclass?
- //TODO: all of this
+ if ( typeof bindingOrString != "string"){
+
+ return bindingOrString.resolve();
+
+// /*ClientEvent*/
+// var event = this._session.getEventHandler().getClientEvent();
+// /*ResolutionInfo*/
+// var info = event.getAttribute("resolverInfo");
+//
+// Leave ResolutionInfo for later
+// if (info==null){
+// return binding.resolve();
+// }
+// else if (info.getResolutionType()==ResolutionInfo.WHOLE_ATTRIBUTE){
+// return binding.resolve(info.getSourceElement(), info.getAttributeName());
+// }
+// return binding.resolve(info.getSourceElement(),info.getTextNode(),info.getNodeIndex());
+
+ } else {
+ var binding
+ = this._bindingResolver.createBindingFromParameterString(bindingOrString);
+ return this.bind(binding);
+ }
+
};
Modified: incubator/xap/trunk/src/xap/data/DataServiceFactory.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/DataServiceFactory.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/DataServiceFactory.js (original)
+++ incubator/xap/trunk/src/xap/data/DataServiceFactory.js Sun Sep 24 19:45:28 2006
@@ -19,7 +19,7 @@
//import java.lang.reflect.InvocationTargetException;
//import java.lang.reflect.Method;
/**
- * The data service factory is responsible for retrieving the DataService for a specified
+ * The data service factory is responsible for retrieving the DataServiceImpl for a specified
* session.
*
* @author dgennaco
@@ -39,7 +39,7 @@
* Get the data service associated with the session.
*
* @param sess{ClientSession} The client session
- * @return a DataService object
+ * @return a DataServiceImpl object
*/
xap.data.DataServiceFactory.getDataService = function (sess) {
/* Exception*/
Added: incubator/xap/trunk/src/xap/data/XmlDataTokens.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/XmlDataTokens.js?view=auto&rev=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/XmlDataTokens.js (added)
+++ incubator/xap/trunk/src/xap/data/XmlDataTokens.js Sun Sep 24 19:45:28 2006
@@ -0,0 +1,63 @@
+
+
+Xap.provide("xap.data.XmlDataTokens") ;
+
+/**
+ * @class
+ * Tokens specific to data that can appear in XML files.
+ *
+ * @author JMargaris
+ *
+ */
+xap.data.XmlDataTokens = function () {
+};
+
+/**
+ * Datasource identifier on a bind/iterator
+ * public static final String
+**/
+xap.data.XmlDataTokens.DATA_SOURCE = "dataSource";
+
+/**
+ * Binding type definition
+ * public static final String
+**/
+xap.data.XmlDataTokens.BINDING_TYPE = "type";
+
+/**
+ * Default value for binding resolver.
+ * public static final String
+**/
+xap.data.XmlDataTokens.DEFAULT_VALUE = "defaultValue";
+
+/**
+ * id
+ * public static final String
+**/
+xap.data.XmlDataTokens.ID = "id";
+
+/**
+ * Typically the select statement on a bind/iterator
+ * public static final String
+**/
+xap.data.XmlDataTokens.SELECT = "select";
+
+/**
+ * Generic class attribute on tags that support user implemented
+ * backing objects.
+ * public static final String
+**/
+xap.data.XmlDataTokens.CLASS = "class";
+
+/**
+ * Formatter attribute on binding
+ * public static final String
+**/
+xap.data.XmlDataTokens.FORMATTER = "formatter";
+
+/**
+ * Name attribute on iterator
+ * public static final String
+**/
+xap.data.XmlDataTokens.NAME = "name";
+
Modified: incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js Sun Sep 24 19:45:28 2006
@@ -1,123 +1,121 @@
-/*
- * 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.
- *
+/*
+ * 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.tags.AttributeConversionException");
+
+Xap.provide("xap.data.bridge.BindingBridge");
+
+Xap.require("xap.taghandling.AttributeConversionException");
Xap.require("xap.data.DataFramework");
Xap.require("xap.data.controller.Binding");
Xap.require("xap.data.controller.BindingType");
Xap.require("xap.data.datasource.DataSourceImpl");
//Xap.require("xap.data.formatter.Formatter");
Xap.require("xap.xml.dom.XapElement");
-Xap.provide("xap.data.bridge.BindingBridge");
-
-/**
- * @class The handler for a binding to a data-source:
-**/
-xap.data.bridge.BindingBridge = function () {
- xap.data.DataFrameworkBridge.call(this);
+Xap.require("xap.data.XmlDataTokens") ;
+Xap.require("xap.data.bridge.DataAttributeConverter") ;
+
+
+/**
+ * @class The handler for a binding to a data-source:
+**/
+xap.data.bridge.BindingBridge = function(){
+ xap.data.bridge.DataFrameworkBridge.call(this);
};
Xap.setupClassAsSubclassOf("xap.data.bridge.BindingBridge", "xap.data.bridge.DataFrameworkBridge");
-/**
- * @public
- * @return {void}
+/**
+ * @public
+ * @return {void}
**/
-xap.data.bridge.BindingBridge.prototype.init = function () {
+xap.data.bridge.BindingBridge.prototype.init = function(){
this.superclass.init(this);
/*XapElement*/
- var me = this.getElement();
-
+ var me = this.getElement();
+
//get all the relevant strings
/*String*/
- var select = me.getAttribute(XmlDataTokens.SELECT);
+ var select = me.getAttribute(xap.data.XmlDataTokens.SELECT);
/*String*/
- var id = me.getAttribute(XmlDataTokens.ID);
+ var id = me.getAttribute(xap.data.XmlDataTokens.ID);
/*String*/
- var dataSourceId = me.getAttribute(XmlDataTokens.DATA_SOURCE);
+ var dataSourceId = me.getAttribute(xap.data.XmlDataTokens.DATA_SOURCE);
/*String*/
- var formatter = me.getAttribute(XmlDataTokens.FORMATTER);
+ var formatter = me.getAttribute(xap.data.XmlDataTokens.FORMATTER);
/*String*/
- var bindingTypeString = me.getAttribute(XmlDataTokens.BINDING_TYPE);
+ var bindingTypeString = me.getAttribute(xap.data.XmlDataTokens.BINDING_TYPE);
/*String*/
- var defaultValue = me.getAttribute(XmlDataTokens.DEFAULT_VALUE);
+ var defaultValue = me.getAttribute(xap.data.XmlDataTokens.DEFAULT_VALUE);
if (defaultValue == null) {
defaultValue = "";
- }
-
- //try to convert the "type" attribute to a binding type
+ }
+
+ //try to convert the "type" attribute to a binding type
//no binding is ok
/*BindingType*/
- var bindingType = BindingType.ONE_TIME;
+ var bindingType = xap.data.controller.BindingType.ONE_TIME;
if (bindingTypeString != null) {
try {
- bindingType = DataAttributeConverter.toBindingType(bindingTypeString);
+ bindingType = xap.data.DataAQttributeConverter.toBindingType(bindingTypeString);
}
- catch (e) {//AttributeConversionException //XmlDataTokens.BINDING_TYPE
- reportInvalidXmlException("BINDING_TYPE:", bindingTypeString, me, e);
-// throw new xap.util.Exception("Problem:: binding type string: "
-// + bindingTypeString
-// + "ndocument element: "
-// + me
-// + "nexception: "
-// + e
-// );
+ catch (e) {//AttributeConversionException
+ this.reportInvalidXmlException(xap.data.XmlDataTokens.BINDING_TYPE, bindingTypeString, me, e);
}
}
/*Binding*/
- var binding = null;
-
- //try to convert the "dataSource" to a data source, can't be null
+ var binding = null;
+
+ //try to convert the "dataSource" to a data source, can't be null
//if we fail don't bother to create the binding itself
try {
/*DataSource*/
- var ds = DataAttributeConverter.toDataSource(dataSourceId, getDataService());
+ var ds = xap.data.bridge.DataAttributeConverter.toDataSource(dataSourceId, this.getDataService());
var sess = this.getSession();
binding = new xap.data.controller.Binding(ds, select, sess, bindingType, defaultValue);
(this.getDataService()).getBindingContainer().addBinding(id, binding);
}
catch (e) { //AttributeConversionException
- this.reportInvalidXmlException(XmlDataTokens.DATA_SOURCE, dataSourceId, me, e);
- }
-
- //if we got to this point OK, add the formatter
-//TODO IMPORTANT turn formatter on when we have one.
-// if (binding!=null){
-// this.addFormatters(formatter,binding);
+ this.reportInvalidXmlException(xap.data.XmlDataTokens.DATA_SOURCE, dataSourceId, me, e);
+ }
+
+ //if we got to this point OK, add the formatter
+//TODO IMPORTANT turn formatter on when we have one.
+// if (binding!=null){
+// this.addFormatters(formatter,binding);
// }
};
-/**
- * @private
- * @return {void}
- *
- * @param formatter{String}
- *@param binding{Binding}
+/**
+ * @private
+ * @return {void}
+ *
+ * @param formatter{String}
+ *@param binding{Binding}
**/
-xap.data.bridge.BindingBridge.prototype.addFormatters = function (formatter, binding) {
+xap.data.bridge.BindingBridge.prototype.addFormatters = function( formatter, binding ){
if (formatter == null) {
return;
- }
-
- //try to convert "formatter" to a formatter
+ }
+
+ //try to convert "formatter" to a formatter
//and add it to the binding
try {
/*Formatter*/
- var f = DataAttributeConverter.toFormatter(formatter, getDataService());
+ var f = xap.data.DataAQttributeConverter.toFormatter(formatter, this.getDataService());
binding.setFormatter(f);
}
catch (e) { //AttributeConversionException
- reportInvalidXmlException(XmlDataTokens.FORMATTER, formatter, getElement(), e);
+ this.reportInvalidXmlException(xap.data.XmlDataTokens.FORMATTER, formatter, this.getElement(), e);
}
};
Modified: incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js Sun Sep 24 19:45:28 2006
@@ -1,53 +1,56 @@
-/*
- * 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.
- *
+/*
+ * 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.bridge.DataAttributeConverter");
Xap.require("xap.taghandling.AttributeConversionException");
-Xap.require("xap.tagshandling.AttributeConverter");
+Xap.require("xap.taghandling.AttributeConverter");
Xap.require("xap.data.DataServiceImpl");
Xap.require("xap.data.controller.BindingType");
-Xap.require("xap.data.datasource.DataSourceImpl");
-// TODO: turn this back on when
+Xap.require("xap.data.datasource.DataSourceImpl");
+Xap.require("xap.data.XmlDataTokens");
+
+
+xap.data.bridge.DataAttributeConverter = function(){
+} ;
+
+
+// TODO: turn this back on when
//Xap.require("xap.data.formatter.Formatter")
-/*private static final String[]*/
-xap.data.bridge.DataAttributeConverter.BINDING_NAMES = [xap.data.controller.BindingType.ONE_WAY.getTypeId(), xap.data.controller.BindingType.ONE_TIME.getTypeId()];
-/*private static final xap.data.controller.BindingType[]*/
-xap.data.bridge.DataAttributeConverter.BINDING_VALUES = [xap.data.controller.BindingType.ONE_WAY, xap.data.controller.BindingType.ONE_TIME];
-
-// Only static methods, no need here:
+
+
+// Only static methods, no need here:
//Xap.setupClassAsSubclassOf("xap.data.bridge.DataAttributeConverter", "xap.taghandling.AttributeConverter");
-/**
- * @public
- * @return {xap.data.controller.BindingType}
- *
- * @param s{String}
- * @throws AttributeConversionException
+/**
+ * @public
+ * @return {xap.data.controller.BindingType}
+ *
+ * @param s{String}
+ * @throws AttributeConversionException
**/
xap.data.bridge.DataAttributeConverter.toBindingType = function (s) {
return xap.taghandling.AttributeConverter.toObjectFromEnum(s, xap.data.bridge.DataAttributeConverter.BINDING_NAMES, xap.data.bridge.DataAttributeConverter.BINDING_VALUES);
};
-
-/**
- * @public
- * @return {DataSource}
- *
- * @param s{String}
- * @param dataService{DataService}
- * @throws AttributeConversionException{
+/**
+ * @public
+ * @return {DataSource}
+ *
+ * @param s{String}
+ * @param dataService{DataServiceImpl}
+ * @throws AttributeConversionException{
**/
xap.data.bridge.DataAttributeConverter.toDataSource = function (s, dataService) {
/*DataSource*/
@@ -56,17 +59,19 @@
dataSource = dataService.getDataSourceContainer().getDataSource(s);
}
if (!dataSource) {
- throw new AttributeConversionException(s, "DATA_SOURCE", null); //XmlDataTokens.DATA_SOURCE
+ throw new AttributeConversionException(s, xap.data.XmlDataTokens.DATA_SOURCE, null);
}
return dataSource;
};
-/**
- * @public
- * @return {Formatter}
- *
- * @param s{String}
- * @param dataService{DataServiceImpl}
- * @throws AttributeConversionException
+
+
+/**
+ * @public
+ * @return {Formatter}
+ *
+ * @param s{String}
+ * @param dataService{DataServiceImpl}
+ * @throws AttributeConversionException
**/
xap.data.bridge.DataAttributeConverter.toFormatter = function (s, dataService) {
/*Formatter*/
@@ -75,17 +80,17 @@
formatter = dataService.getFormatterContainer().getFormatter(s);
}
if (formatter == null) {
- throw new AttributeConversionException(s, XmlDataTokens.FORMATTER, null);
+ throw new AttributeConversionException(s, xap.data.XmlDataTokens.FORMATTER, null);
}
return formatter;
};
-/**
- * @public
- * @return {Object}
- *
- * @param s{String}
- * @param classType{Class}
- * @throws AttributeConversionException
+/**
+ * @public
+ * @return {Object}
+ *
+ * @param s{String}
+ * @param classType{Class}
+ * @throws AttributeConversionException
**/
xap.data.bridge.DataAttributeConverter.toClassInstance = function (s, classType) {
if (s == null) {
@@ -103,17 +108,17 @@
throw new AttributeConversionException(s, "instance of " + classType.getName(), e);
}
};
-/**
- * Converts a string like "jp" or "jp_JP" to a Locale object.
- * @param s
- * @return
- * @throws AttributeConversionException
- *
- * @public
- * @return {Locale}
- *
- * @param s{String}
- * @throws AttributeConversionException
+/**
+ * Converts a string like "jp" or "jp_JP" to a Locale object.
+ * @param s
+ * @return
+ * @throws AttributeConversionException
+ *
+ * @public
+ * @return {Locale}
+ *
+ * @param s{String}
+ * @throws AttributeConversionException
**/
xap.data.bridge.DataAttributeConverter.toLocale = function (s) {
if (s == null) {
@@ -134,21 +139,21 @@
throw new AttributeConversionException(s, "locale", e);
}
};
-/**
- * Converts a string like "PST" to a TimeZone object.
- * Note that if the string argument is null or cannot be converted to a
- * TimeZone object, this method will throw AttributeConversionException
- * (as opposed to returning the default TimeZone). Deciding whether it's
- * appropriate to return a default TimeZone does not belong here.
- *
- * @param s - the string to be converted into a TimeZone object
- * @return TimeZone
- * @throws AttributeConversionException
- *
- * @public
- * @return {TimeZone}
- * @param s{String }
- * @throws AttributeConversionException
+/**
+ * Converts a string like "PST" to a TimeZone object.
+ * Note that if the string argument is null or cannot be converted to a
+ * TimeZone object, this method will throw AttributeConversionException
+ * (as opposed to returning the default TimeZone). Deciding whether it's
+ * appropriate to return a default TimeZone does not belong here.
+ *
+ * @param s - the string to be converted into a TimeZone object
+ * @return TimeZone
+ * @throws AttributeConversionException
+ *
+ * @public
+ * @return {TimeZone}
+ * @param s{String }
+ * @throws AttributeConversionException
**/
xap.data.bridge.DataAttributeConverter.toTimeZone = function (s) {
if (s == null) {
@@ -162,3 +167,7 @@
return zone;
};
+/*private static final String[]*/
+xap.data.bridge.DataAttributeConverter.BINDING_NAMES = [xap.data.controller.BindingType.ONE_WAY.getTypeId(), xap.data.controller.BindingType.ONE_TIME.getTypeId()];
+/*private static final xap.data.controller.BindingType[]*/
+xap.data.bridge.DataAttributeConverter.BINDING_VALUES = [xap.data.controller.BindingType.ONE_WAY, xap.data.controller.BindingType.ONE_TIME];
Modified: incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js Sun Sep 24 19:45:28 2006
@@ -16,19 +16,18 @@
*/
Xap.provide("xap.data.bridge.DataFrameworkBridge");
Xap.require("xap.taghandling.AbstractTagImpl");
-Xap.require("xap.data.DataServiceImpl");
-Xap.require("xap.data.DataServiceFactory") ;
+Xap.require("xap.data.DataServiceImpl");
+Xap.require("xap.data.DataServiceFactory");
//Xap.require("xap.data.datasource.DataSourceContainer") ;
//Xap.require("xap.data.formatter.FormatterContainer") ;
Xap.require("xap.util.LogFactory");
-Xap.require("xap.util.LogFactory");
/**
* The base class for all data framework tags, provides convenience methods
* for common data operations.
*
* @author JMargaris
*/
-xap.data.bridge.DataFrameworkBridge = function() {
+xap.data.bridge.DataFrameworkBridge = function () {
//alert("DataFrameworkBridge start") ;
xap.taghandling.AbstractTagImpl.call(this);
//alert("DataFrameworkBridge stop") ;
@@ -39,7 +38,7 @@
//-----------------------------------------------------------------------
// Public Methods.
//-----------------------------------------------------------------------
-/*public DataService*/
+/*public DataServiceImpl*/
xap.data.bridge.DataFrameworkBridge.prototype.getDataService = function () {
return xap.data.DataServiceFactory.getDataService(this.getSession());
};
@@ -53,7 +52,8 @@
};
/*public void*/
xap.data.bridge.DataFrameworkBridge.prototype.init = function () {
- this.getLog().debug(/*this.getClass().getName()*/"xap.data.bridge.DataFrameworkBridge" + " got element: " + this.getElement());
+ //this.getClass().getName()
+ this.getLog().debug("xap.data.bridge.DataFrameworkBridge" + " got element: " + this.getElement());
};
//-----------------------------------------------------------------------
Modified: incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js Sun Sep 24 19:45:28 2006
@@ -19,7 +19,7 @@
// Superclass:
Xap.provide("xap.data.bridge.DataFrameworkBridge");
Xap.require("xap.session.ClientEvent");
-//Xap.require("xap.client.tags.AttributeConversionException") ;
+Xap.require("xap.taghandling.AttributeConversionException");
//Xap.require("xap.data.DataServiceImpl") ;
//Xap.require("xap.data.InitializationException") ;
//Xap.require("xap.data.datasource.AsynchronousDataSource") ;
@@ -30,6 +30,9 @@
Xap.require("xap.util.LogFactory");
//Xap.require("xap.util.ResourceDictionary") ;
Xap.require("xap.util.UidProvider");
+Xap.require("xap.data.XmlDataTokens") ;
+
+
/**
* The generic data source bridge, it uses the <code>class</code>
* attribute to look up an implementation of
@@ -122,7 +125,7 @@
* @throws InitializationException
*/
xap.data.bridge.DataSourceBridge.prototype.initializeDataSource = function () {
- // XmlDataTokens.ID
+ // xap.data.XmlDataTokens.ID
var id = this.getElement().getAttribute("id");
// if ( id.startsWith( xap.util.UidProvider.XAP_ID_PREFIX )) {
@@ -145,7 +148,7 @@
* to return their own dataSource implementations.
*/
xap.data.bridge.DataSourceBridge.prototype.createDataSource = function () {
- var className = this.getElement().getAttribute("class");
+ var className = this.getElement().getAttribute( xap.data.XmlDataTokens.CLASS );
/*DataSource*/
var dataSource = null;
try {
@@ -155,7 +158,7 @@
}
catch (e) {
// AttributeConversionException
- // reportInvalidXmlException(XmlDataTokens.CLASS,
+ // reportInvalidXmlException(xap.data.XmlDataTokens.CLASS,
// className,getElement(),e);
throw new xap.util.Exception(e);
}
@@ -186,8 +189,7 @@
}
catch (e) {
// This should be an InitializationException instance
- // "null" temporarily[?] replaces DataService.DATA_FRAMEWORK_EXCEPTION_TYPE
- this.getSession().handleException(null, e);
+ this.getSession().handleException(xap.data.DataFramework.DATA_FRAMEWORK_EXCEPTION_TYPE, e);
}
};
Modified: incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js Sun Sep 24 19:45:28 2006
@@ -1,42 +1,47 @@
-/*
- * 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.
- *
- */
-
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
//import java.net.MalformedURLException;
Xap.provide("xap.data.bridge.JavascriptDataSourceBridge");
//superclass:
-Xap.require("xap.data.datasource.AbstractDataSource") ;
-
-// /Xap.require("xap.session.EventHandler") ;
-// /Xap.require("xap.mco.McoInvocationException") ;
-//Xap.require("xap.tags.AttributeConversionException") ;
-//Xap.require("xap.plugin.data.InitializationException") ;
-// /Xap.require("xap.data.datasource.DataSource") ;
-// /Xap.require("xap.data.datasource.ObjectDataSource") ;
-//Xap.require("xap.util.EscapeSyntaxException") ;
+Xap.require("xap.data.datasource.AbstractDataSource") ;
+
+Xap.require("xap.session.EventHandler") ;
+// Xap.require("xap.mco.McoInvocationException") ;
+Xap.require("xap.taghandling.AttributeConversionException");
+//Xap.require("xap.plugin.data.InitializationException") ;
+Xap.require("xap.data.datasource.DataSourceImpl") ;
+Xap.require("xap.data.datasource.AbstractDataSource") ;
+Xap.require("xap.data.datasource.JavascriptDataSource") ;
+//Xap.require("xap.util.EscapeSyntaxException") ;
// /Xap.require("xap.util.ResourceDictionary") ;
Xap.require("xap.xml.dom.XapElement");
Xap.require("xap.data.bridge.DataSourceBridge");
-/**
- * JavascriptDataSourceBridge is a bridge class for the javascriptDataSource tag,
- * stolen liberally from ObjectDataSourceBridge as ported.
- *
- * @author ikaplansky
- * @author mturyn
+Xap.require("xap.data.XmlDataTokens") ;
+
+
+
+/**
+ * JavascriptDataSourceBridge is a bridge class for the javascriptDataSource tag,
+ * stolen liberally from ObjectDataSourceBridge as ported.
+ *
+ * @author ikaplansky
+ * @author mturyn
*/
xap.data.bridge.JavascriptDataSourceBridge = function(){
//alert("JavascriptDataSourceBridge() start");
@@ -44,59 +49,59 @@
//alert("JavascriptDataSourceBridge() end");
};
-Xap.setupClassAsSubclassOf("xap.data.bridge.JavascriptDataSourceBridge", "xap.data.bridge.DataSourceBridge");
-
-
-//-----------------------------------------------------------------------
-// Constants.
-//-----------------------------------------------------------------------
-
+Xap.setupClassAsSubclassOf("xap.data.bridge.JavascriptDataSourceBridge", "xap.data.bridge.DataSourceBridge");
+
+
+//-----------------------------------------------------------------------
+// Constants.
+//-----------------------------------------------------------------------
+
// private static final String
-xap.data.bridge.JavascriptDataSourceBridge.REFRESH_ON_PROPERTY_CHANGE_ATTRIBUTE = "refreshOnPropertyChange";
-
-// {0} refreshOnPropertyChange attribute value
-// {1} datasource element
+xap.data.bridge.JavascriptDataSourceBridge.REFRESH_ON_PROPERTY_CHANGE_ATTRIBUTE = "refreshOnPropertyChange";
+
+// {0} refreshOnPropertyChange attribute value
+// {1} datasource element
// private static final String
-xap.data.bridge.JavascriptDataSourceBridge.INVALID_REFRESH_ON_PROPERTY_CHANGE_MSGID = "invalidRefreshOnPropertyChange";
-
-//-----------------------------------------------------------------------
-// Protected Methods.
-//-----------------------------------------------------------------------
-
+xap.data.bridge.JavascriptDataSourceBridge.INVALID_REFRESH_ON_PROPERTY_CHANGE_MSGID = "invalidRefreshOnPropertyChange";
+
+//-----------------------------------------------------------------------
+// Protected Methods.
+//-----------------------------------------------------------------------
+
//protected DataSource
xap.data.bridge.JavascriptDataSourceBridge.prototype.createDataSource = function () {
/*String*/
- var className = this.getElement().getAttribute("class"); ///*XmlDataTokens.CLASS*/
+ var className = this.getElement().getAttribute( xap.data.XmlDataTokens.CLASS ) ;
/*DataSource*/
var dataSource = null;
try {
dataSource = new xap.data.datasource.JavascriptDataSource();
}
- catch (e) { //AttributeConversionException
-// this.reportInvalidXmlException( XmlDataTokens.CLASS, className,
-// this.getElement(), e );
+ catch (e) { //AttributeConversionException
+// this.reportInvalidXmlException( xap.data.XmlDataTokens.CLASS, className,
+// this.getElement(), e );
// TODO: Restore better exception handling
throw new xap.util.XapException(e);
}
return dataSource;
};
/*protected void*/
-/**
- * @throws InitializationException
+/**
+ * @throws InitializationException
**/
-xap.data.bridge.JavascriptDataSourceBridge.prototype.initializeDataSource = function () {
+xap.data.bridge.JavascriptDataSourceBridge.prototype.initializeDataSource = function () {
// add the DataSource to the container
this.superclass.initializeDataSource.call(this);
this.processConfigurationElement(this.getElement());
-};
-
- //-----------------------------------------------------------------------
- // Private Methods.
+};
+
//-----------------------------------------------------------------------
-/**
- * @private
- * @param dataSourceElement{XapElement}
- * @throws InitializationException
+ // Private Methods.
+ //-----------------------------------------------------------------------
+/**
+ * @private
+ * @param dataSourceElement{XapElement}
+ * @throws InitializationException
**/
xap.data.bridge.JavascriptDataSourceBridge.prototype.processConfigurationElement = function (dataSourceElement) {
try {
@@ -106,31 +111,31 @@
// Might not do this for this class: this.setRefreshOnPropertyChange(dataSource);
this.setSource(dataSource, sourceString);
}
- catch (e) {
+ catch (e) {
// TODO: Decide what sort of exception
throw new xap.util.Exception(e);
- }
-
- // catch ( MalformedURLException e ) {
- // throw new InitializationException(
- // InitializationException.MALFORMED_URL_EXCEPTION_MSGID,
- // ObjectDataSource.class.getName(),
- // e );
- //} catch ( McoException e ) {
- // throw new InitializationException(
- // InitializationException.DATA_ACCESS_EXCEPTION_MSGID,
- // ObjectDataSource.class.getName(),
- // e );
- //} catch ( EscapeSyntaxException e ) {
- // throw new InitializationException(
- // InitializationException.DATA_ACCESS_EXCEPTION_MSGID,
- // ObjectDataSource.class.getName(),
- // e );
+ }
+
+ // catch ( MalformedURLException e ) {
+ // throw new InitializationException(
+ // InitializationException.MALFORMED_URL_EXCEPTION_MSGID,
+ // ObjectDataSource.class.getName(),
+ // e );
+ //} catch ( McoException e ) {
+ // throw new InitializationException(
+ // InitializationException.DATA_ACCESS_EXCEPTION_MSGID,
+ // ObjectDataSource.class.getName(),
+ // e );
+ //} catch ( EscapeSyntaxException e ) {
+ // throw new InitializationException(
+ // InitializationException.DATA_ACCESS_EXCEPTION_MSGID,
+ // ObjectDataSource.class.getName(),
+ // e );
//}
};
-/*
- * @private
- * @param dataSource{ObjectDataSource}
+/*
+ * @private
+ * @param dataSource{ObjectDataSource}
*/
/* My guess is we won't need this, but...
xap.data.bridge.JavascriptDataSourceBridge.prototype.setRefreshOnPropertyChange = function (dataSource) {
@@ -147,13 +152,13 @@
}
}
}
-};
+};
*/
-/**
- * @private
- * @param dataSource{ObjectDataSource}
- * @param sourceString{String}
- * @throws MalformedURLException, McoException, EscapeSyntaxException
+/**
+ * @private
+ * @param dataSource{ObjectDataSource}
+ * @param sourceString{String}
+ * @throws MalformedURLException, McoException, EscapeSyntaxException
**/
xap.data.bridge.JavascriptDataSourceBridge.prototype.setSource = function (dataSource, sourceString) {
/*EventHandler*/
@@ -168,9 +173,9 @@
dataSource.setSource(sourceString);
}
/*Object */
- //var lock = this.getElement().getOwnerDocument().getDomSynchronizationObject();
+ //var lock = this.getElement().getOwnerDocument().getDomSynchronizationObject();
//synchronized( lock ) {
- this.getElement().setAttribute(xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE, sourceString);
+ this.getElement().setAttribute(xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE, sourceString);
//}
};
Modified: incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js Sun Sep 24 19:45:28 2006
@@ -29,6 +29,8 @@
// /Xap.require("xap.util.ResourceDictionary") ;
Xap.require("xap.xml.dom.XapElement") ;
Xap.require("xap.data.bridge.DataSourceBridge") ;
+Xap.require("xap.data.XmlDataTokens") ;
+
/**
* ObjectDataSourceBridge is a bridge class for the objectDataSource tag.
@@ -63,7 +65,7 @@
//protected DataSource
xap.data.bridge.ObjectDataSourceBridge.prototype.createDataSource = function() {
/*String*/
- var className =this.getElement().getAttribute( /*XmlDataTokens.CLASS*/"class" );
+ var className =this.getElement().getAttribute( xap.data.XmlDataTokens.CLASS );
/*DataSource*/
var dataSource = null;
try {
@@ -75,7 +77,7 @@
dataSource = null ; //new ObjectDataSource();
// }
} catch (e) { //AttributeConversionException
-// this.reportInvalidXmlException( XmlDataTokens.CLASS, className,
+// this.reportInvalidXmlException( xap.data.XmlDataTokens.CLASS, className,
// this.getElement(), e );
// TODO: Restore better exception handling
throw new xap.util.XapException(e) ;
Modified: incubator/xap/trunk/src/xap/data/controller/Binding.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/Binding.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/Binding.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/Binding.js Sun Sep 24 19:45:28 2006
@@ -17,10 +17,10 @@
*/
Xap.provide("xap.data.controller.Binding");
Xap.require("xap.util.Vector");
-Xap.require("xap.client.ClientSession");
-Xap.require("xap.UiUpdateQueue");
-Xap.require("xap.data.DataException");
-Xap.require("xap.data.DataService");
+Xap.require("xap.session.ClientSession");
+//Xap.require("xap.UiUpdateQueue");
+//Xap.require("xap.data.DataException");
+Xap.require("xap.data.DataServiceImpl");
Xap.require("xap.data.DataServiceFactory");
//Xap.require("xap.data.datasource.DataAccessException") ;
//Xap.require("xap.data.datasource.DataRetrievalListener") ;
@@ -41,8 +41,7 @@
* @author JMargaris
*
*/
-
- /**
+/**
* Construct a binding to the given data source with the
* given select string.
* <br/>
@@ -68,76 +67,66 @@
* @throws DataControllerException
*/
xap.data.controller.Binding = function () {
- // Crude way to fold in two Java constructors into one JS...
- if (arguments.length == 5) {
- var source = arguments[0];
- var select = arguments[1];
- var session = arguments[2];
- var bindingType = arguments[3];
- var defaultValue = arguments[4];
- this._source = source;
- this._select = select;
- this._session = session;
- this._bindingType = bindingType;
- if (defaultValue != null) {
- this._defaultValue = defaultValue;
- }
- this._currentValue = this._defaultValue;
- } else if (arguments.length == 6) {
- var contextStack = arguments[0];
- var select = arguments[1];
- var name = arguments[2];
- var session = arguments[3];
- var bindingType = arguments[4];
- var defaultValue = arguments[5];
- this._select = select;
- this._session = session;
- this._bindingType = bindingType;
- if (name != null && name.length() > 0) {
- this._source = DataServiceFactory.getDataService(session).getDataSourceContainer().getDataSource(name);
- if (this._source == null) {
- // Find the ancestor iterator context with the
- // specified name, since there was not data source with
- // that name
- this._context = contextStack.getContext(name);
- if (this._context == null) {
- // throw new DataControllerException(DataControllerException.QUICK_BINDING_NAMED_CONTEXT_NOT_FOUND,
- // name);
- throw new xap.util.Exception("Named context for quick binding not found for '" + name + "'.");
- }
- this._source = this._context.getDataSource();
- }
- } else {
- // No name specified, use the current context, this is relative to parent
- this._context = contextStack.getCurrentContext();
- if (this._context == null) {
- // throw new DataControllerException(DataControllerException.RELATIVE_BINDING_WITHOUT_PARENT, select);
- throw new xap.util.Exception("Attempted a relative binding without a parent: '" + select + "'.");
- }
- this._source = this._context.getDataSource();
- }
-
- if (defaultValue != null) {
- this._defaultValue = defaultValue;
- }
-
- this._currentValue = this._defaultValue;
- } //6-argument (contextStack) version
- else {
- throw new xap.util.Exception(
- "Binding must be created using either"
- + "five or six parameters; "
- + arguments.length
- + " were supplied: ["
- + arguments.join(",")
- + "] ."
- ) ;
- }
+ // Crude way to fold in two Java constructors into one JS one...
+ var theLog = xap.util.LogFactory.getLog("xap.data.controller.Binding") ;
+ if (arguments.length == 5) {
+ theLog.debug("5-arg Binding()");
+ var source = arguments[0];
+ var select = arguments[1];
+ var session = arguments[2];
+ var bindingType = arguments[3];
+ var defaultValue = arguments[4];
+ this._source = source;
+ this._select = select;
+ this._session = session;
+ this._bindingType = bindingType;
+ if (defaultValue != null) {
+ this._defaultValue = defaultValue;
+ }
+ this._currentValue = this._defaultValue;
+ } else if (arguments.length == 6) {
+ theLog.debug("6-arg Binding()");
+ var contextStack = arguments[0];
+ var select = arguments[1];
+ var name = arguments[2];
+ var session = arguments[3];
+ var bindingType = arguments[4];
+ var defaultValue = arguments[5];
+ this._select = select;
+ this._session = session;
+ this._bindingType = bindingType;
+ if (name != null && name.length() > 0) {
+ this._source = xap.data.DataServiceFactory.getDataService(session).getDataSourceContainer().getDataSource(name);
+ if (this._source == null) {
+ // Find the ancestor iterator context with the
+ // specified name, since there was not data source with
+ // that name
+ this._context = contextStack.getContext(name);
+ if (this._context == null) {
+ // throw new DataControllerException(DataControllerException.QUICK_BINDING_NAMED_CONTEXT_NOT_FOUND,
+ // name);
+ throw new xap.util.Exception("Named context for quick binding not found for '" + name + "'.");
+ }
+ this._source = this._context.getDataSource();
+ }
+ } else {
+ // No name specified, use the current context, this is relative to parent
+ this._context = contextStack.getCurrentContext();
+ if (this._context == null) {
+ // throw new DataControllerException(DataControllerException.RELATIVE_BINDING_WITHOUT_PARENT, select);
+ throw new xap.util.Exception("Attempted a relative binding without a parent: '" + select + "'.");
+ }
+ this._source = this._context.getDataSource();
+ }
+ if (defaultValue != null) {
+ this._defaultValue = defaultValue;
+ }
+ this._currentValue = this._defaultValue;
+ // END: 6-argument (contextStack) version
+ } else {
+ throw new xap.util.Exception("Binding must be created using either" + "five or six parameters; " + arguments.length + " were supplied: [" + arguments.join(",") + "] .");
+ }
};
-
-
-
-
Xap.setupClassAsSubclassOf("xap.data.controller.Binding", "Object");
/*private*/
xap.data.controller.Binding.prototype._select = null;
@@ -152,43 +141,43 @@
/*private*/
xap.data.controller.Binding.prototype._session;
/*private*/
-xap.data.controller.Binding.prototype._bindingType = BindingType.ONE_TIME;
+xap.data.controller.Binding.prototype._bindingType = xap.data.controller.BindingType.ONE_TIME;
/*private*/
xap.data.controller.Binding.prototype._defaultValue = "";
/*private*/
xap.data.controller.Binding.prototype._currentValue = null;
/**
- * Get the client session for this binding.
- * @public
- * @return {ClientSession} The session.
- */
+ * Get the client session for this binding.
+ * @public
+ * @return {ClientSession} The session.
+ */
xap.data.controller.Binding.prototype.getSession = function () {
- return this._session;
+ return this._session;
};
/**
- * Set the binding type for this binding.
- *
- * @param type{xap.data.controller.BindingType} The binding type.
- */
+ * Set the binding type for this binding.
+ *
+ * @param type{xap.data.controller.BindingType} The binding type.
+ */
/*public*/
xap.data.controller.Binding.prototype.setBindingType = function (type) {
- this._bindingType = type;
+ this._bindingType = type;
};
/**
- * Resolve the specified attribute. This will return the current value associated
- * with this binding and potentially update the value when it becomes available or is
- * modified in the configured data source.
- *
- * @param e{XapElement} the element being parsed
- *
- * @param attributeName{String} the name of the attribute which needs resolution
- *
- * @return the resolved attribute value.
- *
- * @throws DataAccessException
- * @throws MalformedQueryException
- * @throws UnsupportedBindingTypeException
- */
+ * Resolve the specified attribute. This will return the current value associated
+ * with this binding and potentially update the value when it becomes available or is
+ * modified in the configured data source.
+ *
+ * @param e{XapElement} the element being parsed
+ *
+ * @param attributeName{String} the name of the attribute which needs resolution
+ *
+ * @return the resolved attribute value.
+ *
+ * @throws DataAccessException
+ * @throws MalformedQueryException
+ * @throws UnsupportedBindingTypeException
+ */
/*public*/
xap.data.controller.Binding.prototype.resolve = function (e, attributeName) {
//if we are based on a data source, just get the data off that source
@@ -197,15 +186,15 @@
//of a current iteration. So rather than saving it we just look it up
//each time. The timing here is important: this must be called
//DURING iteration
- if (this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
+ if (this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
// Reset the current data value to the default value.
// Since we are a one time binding, we want the current
// data value from the datasource to be retrieved once,
// and only the default value should be able to show up
// prior to that retrieval.
- this._currentValue = this._defaultValue;
- }
- this.requestData();
+ this._currentValue = this._defaultValue;
+ }
+ this.requestData();
// If the binding type is not ONE_TIME or
// the binding type -is- ONE_TIME and the data was not
@@ -213,45 +202,45 @@
// (indicated by the current value being the default value,
// we need to add a bind target so that the data can be set
// at a later time
- if ((_bindingType != BindingType.ONE_TIME) || ((_bindingType == BindingType.ONE_TIME) && (_currentValue == this._defaultValue))) {
- this.addBindTarget(new AttributeValueLocation(e, attributeName));
- }
- return this._currentValue;
-};
-/**
- * Resolve the specified text node. This will return the current value associated
- * with this binding and potentially update the value when it becomes available or is
- * modified in the configured data source.
- *
- * @param e{XapElement} the element being parsed
- *
- * @param value{String} the current value of the text node
- *
- * @param index{integer} the text node's index
- *
- * @return the resolved attribute value.
- *
- * @throws DataAccessException
- * @throws MalformedQueryException
- * @throws UnsupportedBindingTypeException
- */
+ if ((this._bindingType != xap.data.controller.BindingType.ONE_TIME) || ((this._bindingType == xap.data.controller.BindingType.ONE_TIME) && (this._currentValue == this._defaultValue))) {
+ this.addBindTarget(new AttributeValueLocation(e, attributeName));
+ }
+ return this._currentValue;
+};
+/**
+ * Resolve the specified text node. This will return the current value associated
+ * with this binding and potentially update the value when it becomes available or is
+ * modified in the configured data source.
+ *
+ * @param e{XapElement} the element being parsed
+ *
+ * @param value{String} the current value of the text node
+ *
+ * @param index{integer} the text node's index
+ *
+ * @return the resolved attribute value.
+ *
+ * @throws DataAccessException
+ * @throws MalformedQueryException
+ * @throws UnsupportedBindingTypeException
+ */
/*public*/
xap.data.controller.Binding.prototype.resolve = function (e, value, index) {
- /*boolean*/
- var calledInParseInitialChildren = false;
- if (index == -1) {
- index = e.indexOfChild(value);
- calledInParseInitialChildren = true;
- }
- if (this._bindingType == xap.data.controller.Binding.BindingType.ONE_TIME) {
+ /*boolean*/
+ var calledInParseInitialChildren = false;
+ if (index == -1) {
+ index = e.indexOfChild(value);
+ calledInParseInitialChildren = true;
+ }
+ if (this._bindingType == xap.data.controller.Binding.BindingType.ONE_TIME) {
// Reset the current data value to the default value.
// Since we are a one time binding, we want the current
// data value from the datasource to be retrieved once,
// and only the default value should be able to show up
// prior to that retrieval.
- this._currentValue = this._defaultValue;
- }
- this.requestData();
+ this._currentValue = this._defaultValue;
+ }
+ this.requestData();
// If the binding type is not ONE_TIME or
// the binding type -is- ONE_TIME and the data was not
@@ -259,10 +248,10 @@
// (indicated by the current value being the default value,
// we need to add a bind target so that the data can be set
// at a later time
- if ((_bindingType != BindingType.ONE_TIME) || ((_bindingType == BindingType.ONE_TIME) && (_currentValue == this._defaultValue))) {
- this.addBindTarget(new TextNodeLocation(e, index, calledInParseInitialChildren));
- }
- return this._currentValue;
+ if ((this._bindingType != xap.data.controller.BindingType.ONE_TIME) || ((this._bindingType == xap.data.controller.BindingType.ONE_TIME) && (this._currentValue == this._defaultValue))) {
+ this.addBindTarget(new TextNodeLocation(e, index, calledInParseInitialChildren));
+ }
+ return this._currentValue;
};
/**
* Generic resolve. This will return the current value from the data source if it
@@ -278,8 +267,8 @@
xap.data.controller.Binding.prototype.resolve = function () {
// This non-location based resolution can only do its best to do an immediate
// query for the data to get the most current value and return it.
- this.requestData();
- return this._currentValue;
+ this.requestData();
+ return this._currentValue;
};
/**
* Call this method to cause the current value from the data source (or default value) to be
@@ -290,28 +279,28 @@
xap.data.controller.Binding.prototype.setData = function () {
// synchronized (
// this._session.getDocumentRegistry().getUiDocument().getDomSynchronizationObject()) {
- for (var i = 0; i < this._targets.size(); i++) {
- /* TargetLocation */
- var target = this._targets.elementAt(i);
- target.setData(_currentValue, this._session);
- if (this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
+ for (var i = 0; i < this._targets.size(); i++) {
+ /* TargetLocation */
+ var target = this._targets.elementAt(i);
+ target.setData(this._currentValue, this._session);
+ if (this._bindingType == xap.data.controller.BindingType.ONE_TIME) {
// Dangerous...will we have to recast?---add method
// to whatever it actually is, as opposed to
// what (in Java) it was to be recast-to?
// ((XmlLocation)target).invalidate();
- target.invalidate();
- }
- }
+ target.invalidate();
+ }
+ }
// } // end synchronization block
};
/**
- * Adds a formatter to the end of the formatter chain.
- *
- * @param f{Formatter} The formatter.
- */
+ * Adds a formatter to the end of the formatter chain.
+ *
+ * @param f{Formatter} The formatter.
+ */
/*public*/
xap.data.controller.Binding.prototype.setFormatter = function (f) {
- this._formatter = f;
+ this._formatter = f;
};
/*
* Runs an object through the configured formatter.
@@ -320,39 +309,39 @@
*/
/*private*/
xap.data.controller.Binding.prototype.formatObject = function (data) {
- if (this._formatter != null) {
- data = this._formatter.format(data);
- }
- return data;
+ if (this._formatter != null) {
+ data = this._formatter.format(data);
+ }
+ return data;
};
/**
* @param target{Location}
-**/
+ **/
xap.data.controller.Binding.prototype.addBindTarget = function (target) {
- this._targets.addElement(target);
- target.setLocationListener(this);
+ this._targets.addElement(target);
+ target.setLocationListener(this);
};
/**
* @param target{Location}
-**/
+ **/
xap.data.controller.Binding.prototype.removeBindTarget = function (target) {
- this._targets.removeElement(target);
+ this._targets.removeElement(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.size() == 0) {
// IMPORTANT REVISIT revisit this.the source should probably handle listeners removing themselves while
// it is looping through !!!
- this._source.removeListener(this);
- }
+ this._source.removeListener(this);
+ }
};
/**
* @public
* @param location{Location} Binding target's location.<b>
-**/
+ **/
xap.data.controller.Binding.prototype.locationInvalidated = function (location) {
- this.removeBindTarget(location);
+ this.removeBindTarget(location);
};
/*
* @public
@@ -362,62 +351,90 @@
* QueryCompletionListener INTERFACE METHODS
*/
xap.data.controller.Binding.prototype.dataRetrieved = function (query, data, context) {
- this._currentValue = this._defaultValue;
- if (data != null) {
- try {
- this._currentValue = this.getSession().getTypeConversionService().convertToString(formatObject(data));
- }
- catch (dataException) { //DataException
- this._session.handleException(DataService.DATA_FRAMEWORK_EXCEPTION_TYPE, dataException);
+ this._currentValue = this._defaultValue;
+ if (data != null) {
+ try {
+// TODO at least get the formatting back in:
+// this._currentValue = this.getSession().getTypeConversionService().convertToString(formatObject(data));
+ this._currentValue = "" + data ;
+ }
+ catch (dataException) { //DataException
+ this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE, dataException);
// }catch ( conversionException ) { //TypeConversionException
-// this._session.handleException(DataService.DATA_FRAMEWORK_EXCEPTION_TYPE, conversionException);
- }
- }
- this.setDataOnUiUpdateThread();
+// this._session.handleException(DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE, conversionException);
+ }
+ }
+ // TODO implement this
+ //this.setDataOnUiUpdateThread();
};
/*public*/
xap.data.controller.Binding.prototype.getBindingType = function () {
- return this._bindingType;
+ return this._bindingType;
};
/*
- * END - QueryCompletionListener INTERFACE METHODS
- */
+ * END - QueryCompletionListener INTERFACE METHODS
+ */
/**
* @private
* @throws UnsupportedBindingTypeException,MalformedQueryException, DataAccessException
-**/
+ **/
xap.data.controller.Binding.prototype.requestData = function () {
- // Make a request to the data source if necessary
- // If we are in ONE_TIME mode, always call to make sure the
- // latest data is reflected in this object
- // 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 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.
- this._source.getData(this._select, this, this._context);
- }
+// Make a request to the data source if necessary
+// If we are in ONE_TIME mode, always call to make sure the
+// latest data is reflected in this object
+// 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 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.
+ this._source.getData(this._select, this, this._context);
+ }
};
/*private*/
xap.data.controller.Binding.prototype.setDataOnUiUpdateThread = function () {
- try {
- /*UiUpdateQueue*/
- var updateQueue = this.getSession().getUiUpdateQueue();
- if (this.updateQueue.isUiUpdateThread()) {
- this.setData();
- } else {
- this.updateQueue.invokeLater(this.setData, null), null);
- }
- }
- catch (e) { //Exception
- this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE, new xap.util.Exception(e));
+ try {
+ /*UiUpdateQueue*/
+ var updateQueue = this.getSession().getUiUpdateQueue();
+ if (this.updateQueue.isUiUpdateThread()) {
+ this.setData();
+ } else {
+ this.updateQueue.invokeLater(this.setData, null);
+ }
+ }
+ catch (e) { //Exception
+ this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE, new xap.util.Exception(e));
// TODO: better exception
// new DataControllerException(
// DataControllerException.BINDING_SET_SCHEDULE_EXCEPTION,
// e));
- }
+ }
};
+
+/**
+ * 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 Iterator class's implementation.
+ * @return false
+**/
+xap.data.controller.Binding.prototype.isDataSetRetrievalListener = function(){
+ return false ;
+}
+
+
+/**
+ * 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 Iterator class's implementation.
+ * @return true
+**/
+xap.data.controller.Binding.prototype.isDataRetrievalListener = function(){
+ return true ;
+}
Added: incubator/xap/trunk/src/xap/data/controller/BindingContainerImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/BindingContainerImpl.js?view=auto&rev=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/BindingContainerImpl.js (added)
+++ incubator/xap/trunk/src/xap/data/controller/BindingContainerImpl.js Sun Sep 24 19:45:28 2006
@@ -0,0 +1,125 @@
+
+/*
+ * 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.BindingContainerImpl");
+Xap.require("xap.session.ClientSession");
+Xap.require("xap.session.Container");
+/**
+ * @class
+ * @param sess{ClientSession}
+ **/
+xap.data.controller.BindingContainerImpl = function (sess) {
+ xap.session.Container.call(this, sess);
+};
+
+Xap.setupClassAsSubclassOf("xap.data.controller.BindingContainerImpl", "xap.session.Container");
+/* (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#getNames()
+ *
+ * @public
+ * @return {String[]}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.getIds = function () {
+ return this.superclass.getNames.call(this);
+};
+/* (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#hasBinding(xap.data.controller.Binding)
+ *
+ * @public
+ * @return {boolean}
+ *
+ * @param binding{Binding}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.hasBinding = function (binding) {
+ return this.superclass.containsValue.call(this, binding);
+};
+/* (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#addBinding(java.lang.String, xap.data.controller.Binding)
+ *
+ * @public
+ * @return {void}
+ *
+ * @param name{String}
+ * @param binding{Binding}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.addBinding = function (name, binding) {
+ this.superclass.put.call(this, name, binding);
+};
+/* (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#getName(xap.data.controller.Binding)
+ *
+ * @public
+ * @return {String}
+ *
+ * @param binding{Binding}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.getId = function (binding) {
+ return this.superclass.getName.call(this, binding);
+};
+/* (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#getBinding(java.lang.String)
+ *
+ * @public
+ * @return {Binding}
+ *
+ * @param name{String}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.getBinding = function (name) {
+ return this.superclass.get.call(this, name);
+};
+/* (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#removeBinding(xap.data.controller.Binding)
+ *
+ * @public
+ * @return {boolean}
+ *
+ * @param binding{Binding}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.removeBinding = function (binding) {
+ return this.superclass.removeValue.call(this, binding);
+};
+/* (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#removeBinding(java.lang.String)
+ *
+ * @public
+ * @return {Binding}
+ *
+ * @param name{String}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.removeBinding = function (name) {
+ return this.superclass.remove.call(this, name);
+};
+/** (non-Javadoc)
+ * @see xap.data.controller.BindingContainer#getBindings()
+ * Not needed for recasting in JS, but still other
+ * methods might assume they're dealing with a copy
+ * of the original bindings, not them themselves....
+ *
+ * @public
+ * @return {Binding[]}
+ **/
+xap.data.controller.BindingContainerImpl.prototype.getBindings = function () {
+ /*Object []*/
+ var objects = this.getObjects();
+ /*Binding []*/
+ var bindings = Array(objects.length);
+ for (var i = 0; i < bindings.length; i++) {
+ bindings[i] = objects[i];
+ }
+ return bindings;
+};
+
Modified: incubator/xap/trunk/src/xap/data/controller/BindingType.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/BindingType.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/BindingType.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/BindingType.js Sun Sep 24 19:45:28 2006
@@ -1,3 +1,4 @@
+
/*
* Copyright 2006 The Apache Software Foundation.
*
@@ -14,7 +15,6 @@
* limitations under the License.
*
*/
-
/**
* Represents the different types of bindings for data.
*
@@ -27,6 +27,9 @@
* @param typeName{String}
* @param typeId{String}
**/
+
+Xap.provide("xap.data.controller.BindingType") ;
+
xap.data.controller.BindingType = function (typeName, typeId) {
this._typeName = typeName;
this._typeId = typeId;
@@ -40,15 +43,13 @@
* binding information will be discarded.
*/
/*public static final BindingType*/
-xap.data.controller.BindingType.ONE_TIME
- = new xap.data.controller.BindingType("One Time", "ONE_TIME");
+xap.data.controller.BindingType.ONE_TIME = new xap.data.controller.BindingType("One Time", "ONE_TIME");
/**
* Defines one way binding. The data will be resolved any time the
* source data changes.
*/
/*public static final BindingType*/
-xap.data.controller.BindingType.ONE_WAY
- = new xap.data.controller.BindingType("One Way", "ONE_WAY");
+xap.data.controller.BindingType.ONE_WAY = new xap.data.controller.BindingType("One Way", "ONE_WAY");
//-----------------------------------------------------------------------
// Instance Variables.
@@ -72,7 +73,6 @@
//-----------------------------------------------------------------------
// Public Methods.
//-----------------------------------------------------------------------
-
/**
* Returns a human readable representation of the binding type.
*
@@ -82,7 +82,6 @@
xap.data.controller.BindingType.prototype.getTypeName = function () {
return this._typeName;
};
-
/**
* Returns the type identifier, the string representation used in control
* declarations and definitions to indicate the binding type to use.
@@ -93,9 +92,7 @@
**/
xap.data.controller.BindingType.prototype.getTypeId = function () {
return this._typeId;
-};
-
-
+};
/**
* Get the binding type for the associated type identifier string,
* for instance, ONE_WAY.
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=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js Sun Sep 24 19:45:28 2006
@@ -15,16 +15,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.util.LogFactory") ;
-Xap.require("xap.util.ResourceDictionary") ;
-Xap.require("xap.util.Vector") ;
+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.util.LogFactory");
+Xap.require("xap.util.ResourceDictionary");
+Xap.require("xap.util.Vector");
// Xap.require("xap.plugin.data.controller.BindingType") ;
// Xap.require("xap.plugin.data.controller.Context") ;
@@ -32,10 +30,6 @@
// Xap.require("xap.plugin.data.InitializationException") ;
// Xap.require("xap.util.Log") ;
// Xap.require("xap.client.netservice.NetServiceException") ;
-
-
-
-
/**
* An ease-of-use base class for DataSource implementations.
*
@@ -65,9 +59,8 @@
* @author Igor Kaplansky
* @abstract
*/
-xap.data.datasource.AbstractDataSource = function(){
+xap.data.datasource.AbstractDataSource = function () {
};
-
Xap.setupClassAsSubclassOf("xap.data.datasource.AbstractDataSource", "Object");
@@ -181,9 +174,9 @@
**/
xap.data.datasource.AbstractDataSource.prototype.destroy = function () {
/**/
- var _boundQueries = new xap.util.Vector() ;
+ var _boundQueries = new xap.util.Vector();
/**/
- var _postponedQueries = new xap.util.Vector() ;
+ var _postponedQueries = new xap.util.Vector();
};
/**
* @see DataSource#getId()
@@ -204,7 +197,7 @@
* @return {boolean}
**/
xap.data.datasource.AbstractDataSource.prototype.isSupported = function (type) {
- return type == BindingType.ONE_TIME || type == BindingType.ONE_WAY;
+ return type == xap.data.controller.BindingType.ONE_TIME || type == xap.data.controller.BindingType.ONE_WAY;
};
/**
* @see DataSource#getData(String, DataRetrievalListener)
@@ -217,7 +210,7 @@
* @return {void}
**/
xap.data.datasource.AbstractDataSource.prototype.getData = function (query, listener) {
- handleGenericQuery(query, null, listener);
+ this.handleGenericQuery(query, null, listener);
};
/**
* @see DataSource#getDataSet(String, DataSetRetrievalListener)
@@ -228,24 +221,10 @@
* @return {void}
**/
xap.data.datasource.AbstractDataSource.prototype.getDataSet = function (query, listener) {
- handleGenericQuery(query, null, listener);
-};
-/**
- * @see DataSource#getData(String, DataRetrievalListener, Context)
- */
-/**
- * @public
- * @param query{String}
- * @param listener{DataRetrievalListener}
- * @param c
- * @throws DataAccessException, MalformedQueryException,UnsupportedBindingTypeException
- * @return {void}
- **/
-xap.data.datasource.AbstractDataSource.prototype.getData = function (query, listener, context) {
- handleGenericQuery(query, context, listener);
+ this.handleGenericQuery(query, null, listener);
};
/**
- * @see DataSource#getDataSet(String, DataSetRetrievalListener, Context)
+ * @see xap.data.datasource.DataSource#getDataSet
* @public
* @return {void}
* @param query{String}
@@ -254,7 +233,7 @@
* @throws DataAccessException, MalformedQueryException, UnsupportedBindingTypeException
**/
xap.data.datasource.AbstractDataSource.prototype.getData = function (query, listener, context) {
- handleGenericQuery(query, context, listener);
+ this.handleGenericQuery(query, context, listener);
};
/**
* @see DataSource#removeListener(String, RetrievalListener, Context)
@@ -629,7 +608,7 @@
/*QueryRecord*/
var rec = this._postponedQueries.elementAt(i);
try {
- handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
+ this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
}
catch (e) { // DataAccessException,MalformedQueryException
this.getLog().exception(e);
@@ -740,17 +719,17 @@
* @throws DataAccessException, MalformedQueryException,UnsupportedBindingTypeException
**/
xap.data.datasource.AbstractDataSource.prototype.handleGenericQuery = function (query, context, listener) {
- if (!isSupported(listener.getBindingType())) {
+ if (!this.isSupported(listener.getBindingType())) {
throw new UnsupportedBindingTypeException(listener.getBindingType(), this.getClass());
}
// take care of caching queries for later executions when the data
// changes
- if (listener != null && listener.getBindingType() != BindingType.ONE_TIME) {
+ if (listener != null && listener.getBindingType() != xap.data.controller.BindingType.ONE_TIME) {
/*QueryRecord*/
var queryRecord = new QueryRecord(query, context, listener);
this._boundQueries.addElement(queryRecord);
}
- handleQuery(query, context, listener);
+ this.handleQuery(query, context, listener);
};
/**
* A helper method for calling appropriate handleX methods
@@ -766,16 +745,18 @@
* @param listener{RetrievalListener }
**/
xap.data.datasource.AbstractDataSource.prototype.handleQuery = function (query, queryContext, listener) {
- if (listener instanceof DataRetrievalListener) {
+// if (listener instanceof DataRetrievalListener) {
+ if (listener.isDataRetrievalListener()) {
this.handleDataQuery(query, queryContext, listener);
} else {
- if (listener instanceof DataSetRetrievalListener) {
+// if (listener instanceof DataSetRetrievalListener) {
+ if (listener.isDataSetRetrievalListener()) {
this.handleDataSetQuery(query, queryContext, listener);
}
}
};
/**
- * Requeries all bound queries (binding type != BindingType.ONE_TIME)
+ * Requeries all bound queries (binding type != xap.data.controller.BindingType.ONE_TIME)
* @throws DataAccessException
* @throws MalformedQueryException
* @private
Modified: incubator/xap/trunk/src/xap/data/datasource/DataSourceContainerImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/DataSourceContainerImpl.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/DataSourceContainerImpl.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/DataSourceContainerImpl.js Sun Sep 24 19:45:28 2006
@@ -37,7 +37,7 @@
* @return {String[]}
**/
xap.data.datasource.DataSourceContainerImpl.prototype.getIds = function () {
- return xap.session.Container.getNames.call(this);
+ return this.superclass.getNames.call(this);
};
/* (non-Javadoc)
* @see xap.data.datasource.DataSourceContainer#hasDataSource(xap.data.datasource.DataSource)
@@ -48,7 +48,7 @@
* @param dataSource{DataSource}
**/
xap.data.datasource.DataSourceContainerImpl.prototype.hasDataSource = function (dataSource) {
- return xap.session.Container.containsValue.call(this, dataSource);
+ return this.superclass.containsValue.call(this, dataSource);
};
/* (non-Javadoc)
@see xap.data.datasource.DataSourceContainer#addDataSource(java.lang.String, xap.data.datasource.DataSource)
@@ -71,7 +71,7 @@
* @param dataSource{DataSource}
**/
xap.data.datasource.DataSourceContainerImpl.prototype.getId = function (dataSource) {
- return xap.session.Container.getName.call(this, dataSource);
+ return this.superclass.getName.call(this, dataSource);
};
/* (non-Javadoc)
* @see xap.data.datasource.DataSourceContainer#getDataSource(java.lang.String)
@@ -82,7 +82,7 @@
* @param name{String}
**/
xap.data.datasource.DataSourceContainerImpl.prototype.getDataSource = function (name) {
- return xap.session.Container.get.call(this, name);
+ return this.superclass.get.call(this, name);
};
/* (non-Javadoc)
* @see xap.data.datasource.DataSourceContainer#removeDataSource(xap.data.datasource.DataSource)
@@ -93,19 +93,9 @@
* @param dataSource{DataSource}
**/
xap.data.datasource.DataSourceContainerImpl.prototype.removeDataSource = function (dataSource) {
- return xap.session.Container.removeValue.call(dataSource);
-};
-/* (non-Javadoc)
- * @see xap.data.datasource.DataSourceContainer#removeDataSource(java.lang.String)
- *
- * @public
- * @return {DataSource}
- *
- * @param name{String}
-**/
-xap.data.datasource.DataSourceContainerImpl.prototype.removeDataSource = function (name) {
- return this.superclass.remove.call(this, name);
+ return this.superclass.removeValue.call(dataSource);
};
+
/* (non-Javadoc)
* @see xap.data.datasource.DataSourceContainer#getDataSources()
*
Modified: incubator/xap/trunk/src/xap/data/datasource/DataSourceImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/DataSourceImpl.js?view=diff&rev=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/DataSourceImpl.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/DataSourceImpl.js Sun Sep 24 19:45:28 2006
@@ -241,8 +241,9 @@
* @return {boolean}
**/
xap.data.datasource.DataSourceImpl.prototype.isSupported = function( type ) {
- return type == BindingType.ONE_TIME ||
- type == BindingType.ONE_WAY;
+ return type == xap.data.controller.BindingType.ONE_TIME
+ || type == xap.data.controller.BindingType.ONE_WAY
+ ;
}
/**
@@ -256,7 +257,7 @@
* @return {void}
**/
xap.data.datasource.DataSourceImpl.prototype.getData = function(query, listener ){
- handleGenericQuery( query, null, listener );
+ this.handleGenericQuery( query, null, listener );
}
/**
@@ -268,7 +269,7 @@
* @return {void}
**/
xap.data.datasource.DataSourceImpl.prototype.getDataSet = function( query, listener ){
- handleGenericQuery( query, null, listener );
+ this.handleGenericQuery( query, null, listener );
}
/**
@@ -283,7 +284,7 @@
* @return {void}
**/
xap.data.datasource.DataSourceImpl.prototype.getData = function( query, listener, context ) {
- handleGenericQuery( query, context, listener );
+ this.handleGenericQuery( query, context, listener );
}
/**
@@ -296,7 +297,7 @@
* @throws DataAccessException, MalformedQueryException, UnsupportedBindingTypeException
**/
xap.data.datasource.DataSourceImpl.prototype.getData = function( query, listener, context ){
- handleGenericQuery( query, context, listener );
+ this.handleGenericQuery( query, context, listener );
}
/**
@@ -854,14 +855,19 @@
* @throws DataAccessException, MalformedQueryException,UnsupportedBindingTypeException
**/
xap.data.datasource.DataSourceImpl.prototype.handleGenericQuery = function( query, context, listener ) {
- if( ! isSupported( listener.getBindingType() )) {
- throw new UnsupportedBindingTypeException( listener.getBindingType(),
- getClass());
+ if( ! this.isSupported( listener.getBindingType() )) {
+// throw new UnsupportedBindingTypeException( listener.getBindingType(),
+// getClass());
+// TODO: Use correct exception:
+ throw new xap.util.Exception("Unsupported binding type: "
+ +listener.getBindingType()
+ +"."
+ ) ;
}
// take care of caching queries for later executions when the data
// changes
if ( listener != null &&
- listener.getBindingType() != BindingType.ONE_TIME ) {
+ listener.getBindingType() != xap.data.controller.BindingType.ONE_TIME ) {
/*QueryRecord*/
var queryRecord = new QueryRecord( query, context, listener );
this._boundQueries.addElement( queryRecord );
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=449550&r1=449549&r2=449550
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js Sun Sep 24 19:45:28 2006
@@ -50,5 +50,44 @@
xap.data.datasource.JavascriptDataSource.prototype.initialize = function (id, session, dataSourceElement) {
xap.data.datasource.AbstractDataSource.prototype.initialize.call(this, id, session, dataSourceElement);
this._propertyChangeListener = new xap.data.events.GenericPropertyChangeListener(this);
-};
+};
+
+
+
+/**
+ * @see AbstractDataSource#handleDataQuery( String, Context,
+ * DataRetrievalListener )
+ *
+ * @protected
+ * @param query{String}
+ * @param context{Context}
+ * @param listener{DataRetrievalListener}
+ * @throws DataAccessException, MalformedQueryException
+ * @return {void}
+**/
+xap.data.datasource.JavascriptDataSource.prototype.handleDataQuery = function (query, context, listener) {
+ var contextObject = this.getSource();
+ if (context != null) {
+ contextObject = context.getData();
+ }
+ if (contextObject == null) {
+ this.addPostponedQuery(query, context, listener);
+ } else {
+ /*Object*/
+ var theData = null
+ var theScript = contextObject+"."+query ;
+ try {
+ theData = eval(theScript) ;
+ } catch (anException){
+ throw new xap.util.Exception("Could not evaluate: '"
+ + theScript
+ +"'"
+ ) ;
+ }
+
+
+ listener.dataRetrieved(query, theData, context);
+ }
+};
+