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 2006/12/19 07:36:34 UTC
svn commit: r488567 - in /incubator/xap/trunk:
WebContent/examples/dataBinding/ src/xap/data/ src/xap/data/bridge/
src/xap/data/controller/ src/xap/data/datasource/ src/xap/data/formatter/
Author: jmargaris
Date: Mon Dec 18 23:36:32 2006
New Revision: 488567
URL: http://svn.apache.org/viewvc?view=rev&rev=488567
Log:
lots of cleanup, object-style data source working again
Added:
incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.html (with props)
incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.xal
Removed:
incubator/xap/trunk/WebContent/examples/dataBinding/AnArray.js
incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js
incubator/xap/trunk/WebContent/examples/dataBinding/EmployeesArrays_json.js
incubator/xap/trunk/WebContent/examples/dataBinding/decimalFormatter.html
incubator/xap/trunk/WebContent/examples/dataBinding/decimalFormatter.xal
incubator/xap/trunk/WebContent/examples/dataBinding/formatterChain.html
incubator/xap/trunk/WebContent/examples/dataBinding/formatterChain.xal
incubator/xap/trunk/WebContent/examples/dataBinding/index.html
incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html
incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal
incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.html
incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal
incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.html
incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.xal
incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.html
incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.xal
incubator/xap/trunk/WebContent/examples/dataBinding/playlistfeed.xml
incubator/xap/trunk/WebContent/examples/dataBinding/rss_example.html
incubator/xap/trunk/WebContent/examples/dataBinding/rss_example.xal
incubator/xap/trunk/WebContent/examples/dataBinding/simpleDocumentDatasource_0.html
incubator/xap/trunk/WebContent/examples/dataBinding/simpleDocumentDatasource_0.xal
incubator/xap/trunk/WebContent/examples/dataBinding/titles.xml
incubator/xap/trunk/WebContent/examples/dataBinding/translator.xml
incubator/xap/trunk/src/xap/data/bridge/JavascriptDataSourceBridge.js
incubator/xap/trunk/src/xap/data/bridge/JsonDataSourceBridge.js
incubator/xap/trunk/src/xap/data/datasource/DataSourceContainerImpl.js
incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js
incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js
incubator/xap/trunk/src/xap/data/formatter/FormatterContainerImpl.js
Modified:
incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js
incubator/xap/trunk/WebContent/examples/dataBinding/nestedIterators.xal
incubator/xap/trunk/src/xap/data/DataFramework.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/FormatterBridge.js
incubator/xap/trunk/src/xap/data/bridge/FormatterChainBridge.js
incubator/xap/trunk/src/xap/data/bridge/IteratorBridge.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/BindingResolver.js
incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js
incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js
Modified: incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/Employees_json.js Mon Dec 18 23:36:32 2006
@@ -1,13 +1,22 @@
-var employees = {
- "array":[
- {"lname":"Doe", "fname":"John", "id":"001"},
- {"lname":"Roe", "fname":"Mary", "id":"002"},
- {"lname":"Smith", "fname":"Winston", "id":"003.14159265"},
- {"lname":"O'Brien", "fname":"Julia", "id":"004"},
- {"lname":"Venture", "fname":"Thaddeus", "id":"005"},
- {"lname":"Savage", "fname":"Danforth \"Doc\"", "id":"006"},
- {"lname":"Brown", "fname":"Jordan", "id":"007"},
- {"lname":"Puneval", "fname":"Theophilus", "id":"008"}
+{
+ employees:[
+ {
+ 'lname': "Doe",
+ 'fname':"John",
+ 'id':"001"
+ },
+
+ {
+ 'lname': "Roe",
+ 'fname':"Mary",
+ 'id':"002"
+ },
+
+ {
+ 'lname': "Smith",
+ 'fname':"Winston",
+ 'id':"003"
+ }
]
}
Modified: incubator/xap/trunk/WebContent/examples/dataBinding/nestedIterators.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/nestedIterators.xal?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/nestedIterators.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/nestedIterators.xal Mon Dec 18 23:36:32 2006
@@ -16,9 +16,9 @@
id="customerCount"
/>
- <borderPane>
+ <verticalBoxPane>
- <table borderPosition="center">
+ <table width="500px">
<column>
<header text="Cust id" />
@@ -76,7 +76,7 @@
height="30"
/>
- </borderPane>
+ </verticalBoxPane>
</xal>
<!-- -->
Added: incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.html?view=auto&rev=488567
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.html (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.html Mon Dec 18 23:36:32 2006
@@ -0,0 +1,31 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Iterating over records from an XML document data source:</title>
+
+ <style type="text/css">
+ <!--
+ @import url(../../css/xapDefault.css);
+ -->
+ </style>
+
+ <!-- Keep dojo from trying to scan this whole page for dojoType'd tags: -->
+ <script type="text/javascript">
+ djConfig = {
+ parseWidgets: false
+ };
+ </script>
+
+ <script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
+ <!-- For MCO code -->
+ <script language="JavaScript" type="text/javascript" src="Layout.js"> </script>
+ </head>
+
+ <body onload="Xap.createEmbeddedApplications();">
+ <h3>Employee data from an XML document:</h3>
+ <div style="left:100px;top:100px" startPage="simpleEmployeesJson.xal"></div>
+ <div top="380px">
+ (see <a href="simpleEmployeesJson.xal">simpleEmployeesJson.xal</a>, <a href="Employees_json.js">Employees_json.js</a>.)
+ </div>
+ </body>
+</html>
Propchange: incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.xal?view=auto&rev=488567
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.xal (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/simpleEmployeesJson.xal Mon Dec 18 23:36:32 2006
@@ -0,0 +1,99 @@
+<xal xmlns="http://openxal.org/ui" xmlns:xal="http://openxal.org/ui">
+
+ <objectDataSource
+ xmlns="http://openxal.org/core/data"
+ id="myDataSource"
+ source="Employees_json.js"
+ />
+
+ <messageFormatter
+ xmlns="http://openxal.org/core/data"
+ id="firstNameList"
+ format="The first 3 names are {0}, {1} and {2}"
+ />
+
+ <messageFormatter
+ xmlns="http://openxal.org/core/data"
+ id="middleNameCount"
+ format="The number of middle names is {0} (to 2 decimal places)"
+ />
+
+
+ <decimalFormatter
+ xmlns="http://openxal.org/core/data"
+ id="decimalFormat"
+ format="0.00"
+ />
+
+ <binding
+ xmlns="http://openxal.org/core/data"
+ dataSource="myDataSource"
+ select="'# Items:' + this.employees.length"
+ id="employeeCount"
+ />
+
+
+ <formatterChain id="middleNameFormatter" xmlns="http://openxal.org/core/data">
+ <formatterReference formatter="decimalFormat"/>
+ <formatterReference formatter="middleNameCount"/>
+ </formatterChain>
+
+
+
+
+ <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
+ <xm:append select="/ui">
+
+
+ <xal:table id="testComponent" width="750px" height="400px">
+
+ <xal:column dataType="number">
+ <xal:header width="60px" text="i.d." fontWeight="bolder" fontFamily="Garamond" fontSize="11pt"/>
+ </xal:column>
+ <xal:column>
+ <xal:header width="180px" text="Last name" fontWeight="bolder" fontFamily="Garamond" fontSize="11pt"/>
+ </xal:column>
+ <xal:column>
+ <xal:header width="180px" text="First name" fontWeight="bolder" fontFamily="Garamond" fontSize="11pt"/>
+ </xal:column>
+ <xal:column>
+ <xal:header width="180px" text="Middle name" fontWeight="bolder" fontFamily="Garamond" fontSize="11pt"/>
+ </xal:column>
+
+
+ <!-- Iterator -->
+ <iterator xmlns="http://openxal.org/core/data" name="anIterator" dataSource="myDataSource" select="this.employees" type="ONE_TIME">
+
+ <xal:row>
+ <xal:cell text="{*('this.id')}" fontFamily="Garamond" fontSize="11pt"/>
+ <xal:cell text="{*('this.lname')}" fontFamily="Garamond" fontSize="11pt"/>
+ <xal:cell text="{*('this.fname')}" fontFamily="Garamond" fontSize="11pt"/>
+ <xal:cell text="{*('this.mname')}" fontFamily="Garamond" fontSize="11pt"/>
+ </xal:row>
+ </iterator>
+ </xal:table>
+
+
+ <label fontSize="11pt"
+ text="{ bind(binding:employeeCount) }"
+ />
+
+ <label
+ text="\{ bind(binding:employeeCount) } is the binding string above"
+ />
+
+ <label height="10px"/>
+
+ <label text="{ bind('dataSource=myDataSource;select=[this.employees[0].fname, this.employees[1].fname, this.employees[2].fname];formatter=firstNameList')}"/>
+ <label text="\{ bind('dataSource=myDataSource;select=[this.employees[0].fname, this.employees[1].fname, this.employees[2].fname];formatter=firstNameList')}"/>
+
+ <label height="10px"/>
+
+ <label text="{ bind('dataSource=myDataSource;select=this.employees.length;formatter=decimalFormat')}"/>
+ <label text="\{ bind('dataSource=myDataSource;select=this.employees.length;formatter=decimalFormat')}"/>
+
+ <label height="10px"/>
+
+ </xm:append>
+ </xm:modifications>
+</xal>
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=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/DataFramework.js (original)
+++ incubator/xap/trunk/src/xap/data/DataFramework.js Mon Dec 18 23:36:32 2006
@@ -25,8 +25,6 @@
Xap.require("xap.data.controller.Binding") ;
Xap.require("xap.session.Container") ;
Xap.require("xap.data.controller.BindingType") ;
-Xap.require("xap.data.datasource.DataSourceContainerImpl") ;
-Xap.require("xap.data.formatter.FormatterContainerImpl") ;
Xap.require("xap.util.EscapeSyntaxException") ;
Xap.require("xap.resolver.ResolutionInfo");
@@ -45,11 +43,11 @@
**/
xap.data.DataFramework = function(sess) {
this._session = sess;
- this._dataSourceContainer = new xap.data.datasource.DataSourceContainerImpl(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.data.formatter.FormatterContainerImpl(sess);
+ this._formatterContainer = new xap.session.Container(sess);
this._iteratorContainer = new xap.data.controller.IteratorContainerImpl(sess);
//add the dataSourceContainer to the container of containers
@@ -187,9 +185,9 @@
// Implementors of DataService
-/*private FormatterContainerImpl */
+/*private container */
xap.data.DataFramework.prototype._formatterContainer = null;
-/*private DataSourceContainerImpl */
+/*private container */
xap.data.DataFramework.prototype._dataSourceContainer = null;
/**
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=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js Mon Dec 18 23:36:32 2006
@@ -48,7 +48,7 @@
/*DataSource*/
var dataSource = null;
if (s != null) {
- dataSource = dataService.getDataSourceContainer().getDataSource(s);
+ dataSource = dataService.getDataSourceContainer().get(s);
}
if (!dataSource) {
throw new xap.taghandling.AttributeConversionException(s, xap.data.bridge.XmlDataTokens.DATA_SOURCE, null);
@@ -69,7 +69,7 @@
/*Formatter*/
var formatter = null;
if (s != null) {
- formatter = dataService.getFormatterContainer().getFormatter(s);
+ formatter = dataService.getFormatterContainer().get(s);
}
if (formatter == null) {
throw new xap.taghandling.AttributeConversionException(s, xap.data.bridge.XmlDataTokens.FORMATTER, null);
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=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js Mon Dec 18 23:36:32 2006
@@ -17,8 +17,6 @@
Xap.provide("xap.data.bridge.DataFrameworkBridge");
Xap.require("xap.taghandling.AbstractTagImpl");
Xap.require("xap.data.DataFramework");
-Xap.require("xap.data.datasource.DataSourceContainerImpl") ;
-Xap.require("xap.data.formatter.FormatterContainerImpl") ;
Xap.require("xap.util.LogFactory");
/**
* The base class for all data framework tags, provides convenience methods
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=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js Mon Dec 18 23:36:32 2006
@@ -104,7 +104,7 @@
}
this._dataSource.initialize(id, this.getSession(), this.getElement());
- this.getDataSourceContainer().addDataSource(id, this._dataSource);
+ this.getDataSourceContainer().put(id, this._dataSource);
};
/**
* Creates the data source. The default implementation looks at the
Modified: incubator/xap/trunk/src/xap/data/bridge/FormatterBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/FormatterBridge.js?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/FormatterBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/FormatterBridge.js Mon Dec 18 23:36:32 2006
@@ -101,7 +101,7 @@
/*String*/
var id = this.getElement().getAttribute(xap.data.bridge.XmlDataTokens.ID);
this._formatter.initialize(id, this.getSession(), this.getElement());
- this.getFormatterContainer().addFormatter(id, this._formatter);
+ this.getFormatterContainer().put(id, this._formatter);
};
/**
* Creates the formatter. The default implementation looks at the
Modified: incubator/xap/trunk/src/xap/data/bridge/FormatterChainBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/FormatterChainBridge.js?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/FormatterChainBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/FormatterChainBridge.js Mon Dec 18 23:36:32 2006
@@ -119,7 +119,7 @@
var formatterId = formatterRef.getAttribute(xap.data.bridge.FormatterChainBridge.FORMATTER_ID_ATTRIBUTE);
if (formatterId != null) {
/*Formatter*/
- var f = this.getFormatterContainer().getFormatter(formatterId);
+ var f = this.getFormatterContainer().get(formatterId);
if (f != null) {
chain.appendFormatter(f);
} else {
Modified: incubator/xap/trunk/src/xap/data/bridge/IteratorBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/IteratorBridge.js?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/IteratorBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/IteratorBridge.js Mon Dec 18 23:36:32 2006
@@ -94,7 +94,7 @@
name = element.getAttribute(xmlDataTokens.ID);
}
if (dataSourceId != null) {
- dataSource = this.getDataSourceContainer().getDataSource(dataSourceId);
+ dataSource = this.getDataSourceContainer().get(dataSourceId);
}
//if there is a data source, use it
if (dataSource) {
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=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js Mon Dec 18 23:36:32 2006
@@ -5,7 +5,7 @@
* 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
+ * 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,
@@ -14,183 +14,34 @@
* limitations under the License.
*
*/
+
+Xap.provide("xap.data.bridge.ObjectDataSourceBridge");
-Xap.provide("xap.data.bridge.ObjectDataSourceBridge") ;
-Xap.require("xap.xml.dom.XapElement") ;
-Xap.require("xap.data.bridge.DataSourceBridge") ;
-Xap.require("xap.data.bridge.XmlDataTokens") ;
+Xap.require("xap.data.datasource.ObjectDataSource");
+Xap.require("xap.data.bridge.DataSourceBridge");
-/**
- * ObjectDataSourceBridge is a bridge class for the objectDataSource tag.
- *
- * @version $Revision: 1.12 $
- * @author ikaplansky
- */
xap.data.bridge.ObjectDataSourceBridge = function () {
- xap.data.bridge.DataSourceBridge.call(this) ;
+ xap.data.bridge.DataSourceBridge.call(this);
};
-
-Xap.setupClassAsSubclassOf("xap.data.bridge.ObjectDataSourceBridge","xap.data.bridge.DataSourceBridge") ;
-
-//-----------------------------------------------------------------------
-// Constants.
-//-----------------------------------------------------------------------
+Xap.setupClassAsSubclassOf("xap.data.bridge.ObjectDataSourceBridge", "xap.data.bridge.DataSourceBridge");
-// private static final String
-xap.data.bridge.ObjectDataSourceBridge.REFRESH_ON_PROPERTY_CHANGE_ATTRIBUTE = "refreshOnPropertyChange";
-
-// {0} refreshOnPropertyChange attribute value
-// {1} datasource element
-// private static final String
-xap.data.bridge.ObjectDataSourceBridge.INVALID_REFRESH_ON_PROPERTY_CHANGE_MSGID = "invalidRefreshOnPropertyChange";
-
//-----------------------------------------------------------------------
// Protected Methods.
//-----------------------------------------------------------------------
-
+
//protected DataSource
-xap.data.bridge.ObjectDataSourceBridge.prototype.createDataSource = function() {
- /*String*/
- var className =this.getElement().getAttribute( xap.data.bridge.XmlDataTokens.CLASS );
- /*DataSource*/
- var dataSource = null;
- try {
-// if ( className != null &&
-// className.trim().length !=0 ) {
-// dataSource = /*(DataSource)*/
-// DataAttributeConverter.toClassInstance( className, ObjectDataSource );
-// } else {
- dataSource = null ; //new ObjectDataSource();
-// }
- } catch (e) { //AttributeConversionException
-// this.reportInvalidXmlException( xap.data.bridge.XmlDataTokens.CLASS, className,
-// this.getElement(), e );
- // TODO: Restore better exception handling
- throw new xap.util.XapException(e) ;
- }
- return dataSource;
-}
+xap.data.bridge.ObjectDataSourceBridge.prototype.createDataSource = function () {
+ return new xap.data.datasource.ObjectDataSource();
+};
+
+xap.data.bridge.ObjectDataSourceBridge.prototype.initializeDataSource = function () {
+ xap.data.bridge.DataSourceBridge.prototype.initializeDataSource.call(this);
+ var uri = this.getElement().getAttribute(xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE);
-/*protected void*/
-/**
- * @throws InitializationException
-**/
-xap.data.bridge.ObjectDataSourceBridge.prototype.initializeDataSource = function(){
- // add the DataSource to the container
- this.superclass.initializeDataSource();
- this.processConfigurationElement(this.getElement() );
+ //TODO if they do something like mco:myMco use that as the data source!
+ if (uri){
+ this._dataSource.loadSourceFromServer(uri);
}
-
- //-----------------------------------------------------------------------
- // Private Methods.
- //-----------------------------------------------------------------------
-
-/**
- * @private
- * @param dataSourceElement{XapElement}
- * @throws InitializationException
-**/
-xap.data.bridge.ObjectDataSourceBridge.prototype.processConfigurationElement = function( dataSourceElement ){
- try {
- /*ObjectDataSource*/
- var dataSource = /*(ObjectDataSource)*/ this.getDataSource();
- /*String*/
- var sourcePath = this.dataSourceElement.getAttribute(
- SOURCE_ATTRIBUTE );
- setRefreshOnPropertyChange( dataSource );
- setSource ( dataSource, sourcePath );
- } 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 );
- //}
- }
-
-/**
- * @private
- * @param dataSource{ObjectDataSource}
-**/
-xap.data.bridge.ObjectDataSourceBridge.prototype.setRefreshOnPropertyChange = function( dataSource ) {
- /*String*/
- var refreshOnPropertyChange = this.getElement().getAttribute(
- REFRESH_ON_PROPERTY_CHANGE_ATTRIBUTE );
- if ( refreshOnPropertyChange != null ) {
- refreshOnPropertyChange = refreshOnPropertyChange.trim().
- toLowerCase();
- if( refreshOnPropertyChange.equals( "true" )) {
- this.dataSource.setRefreshOnPropertyChange( true );
- } else if ( refreshOnPropertyChange.equals( "false" )) {
- this.dataSource.setRefreshOnPropertyChange( false );
- } else {
- this.getLog().error(
-
- ResourceDictionary.getMessage(
- INVALID_REFRESH_ON_PROPERTY_CHANGE_MSGID,
- xap.data.datasource.ObjectDataSourceBridge,
- [
- this.refreshOnPropertyChange,
- this.getElement().toXml( true )
- ]
- )
- );
- }
- }
-}
-
-/*private void*/
-/**
- * @param dataSource{ObjectDataSource}
- * @param sourcePath{String}
- * @throws MalformedURLException, McoException, EscapeSyntaxException
-**/
-xap.data.bridge.ObjectDataSourceBridge.prototype.setSource = function( dataSource, sourcePath ) {
- /*EventHandler*/
- var eventHandler = this.getSession().getEventHandler();
- if ( this.sourcePath != null && sourcePath.trim().length != 0 ) {
- /*String*/
- var objectUrl = eventHandler.qualifyObjectUrl( sourcePath );
- if ( objectUrl == null ) {
- // sourceUrl is an HTTP URL
- this.sourcePath = createQualifiedUrlAsString( sourcePath );
- this.dataSource.loadObjectFromUrl( sourcePath );
- } else {
- this.sourcePath = objectUrl;
- /*Object*/
- var source = eventHandler.resolveMcoArgument( sourcePath,
- this.getElement(),
- null );
- if ( source == null ) {
- throw new IllegalArgumentException (
- ResourceDictionary.getMessage(
- NULL_SOURCE_MSGID,
- xap.data.bridge.DataSourceBridge,
- this.sourcePath ));
- }
- this.dataSource.setSource( source );
- }
- /*Object */
- var lock = this.getElement().getOwnerDocument().
- thisgetDomSynchronizationObject();
- //synchronized( lock ) {
- this.getElement().setAttribute( SOURCE_ATTRIBUTE, sourcePath );
- //}
- }
-}
+};
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=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/Binding.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/Binding.js Mon Dec 18 23:36:32 2006
@@ -59,7 +59,7 @@
binding._session = session;
binding._bindingType = bindingType;
if (name && name.length > 0) {
- binding._source = xap.data.DataFramework.getDataService(session).getDataSourceContainer().getDataSource(name);
+ binding._source = xap.data.DataFramework.getDataService(session).getDataSourceContainer().get(name);
if (!binding._source) {
// Find the ancestor iterator context with the
// specified name, since there was not data source with
Modified: incubator/xap/trunk/src/xap/data/controller/BindingResolver.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/BindingResolver.js?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/BindingResolver.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/BindingResolver.js Mon Dec 18 23:36:32 2006
@@ -152,7 +152,7 @@
}
if (xap.data.bridge.XmlDataTokens.FORMATTER == parameterName ) {
if (parameterValue != null) {
- formatter = dataService.getFormatterContainer().getFormatter(parameterValue);
+ formatter = dataService.getFormatterContainer().get(parameterValue);
}
} else {
if (xap.data.bridge.XmlDataTokens.BINDING_TYPE == parameterName ) {
Modified: incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/IteratorContainerImpl.js Mon Dec 18 23:36:32 2006
@@ -27,11 +27,6 @@
Xap.setupClassAsSubclassOf("xap.data.controller.IteratorContainerImpl", "xap.session.Container");
-xap.data.controller.IteratorContainerImpl.prototype.getNames = function () {
- return this.superclass.getNames.call(this);
-};
-
-
xap.data.controller.IteratorContainerImpl.prototype.addIterator = function (name, iterator) {
/*Vector*/
var v = this.superclass.get.call(this, name);
Modified: incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js?view=diff&rev=488567&r1=488566&r2=488567
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js Mon Dec 18 23:36:32 2006
@@ -1,360 +1,115 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-**/
-
-Xap.provide("xap.data.datasource.ObjectDataSource");
-
-Xap.require("xap.session.ClientSession");
-Xap.require("xap.util.LogFactory");
-Xap.require("xap.util.ResourceDictionary");
-Xap.require("xap.xml.dom.XapElement");
-/**
- * @class
- * ObjectDataSource encapsulates data contained within some object. The object's
- * location is specified as a 'source' attribute on the datasource
- * element. The source can be one of the following:
- *
- * <ul>
- * <li>Absolute HTTP URL <p/>
- * The destination is expected to write out a serialized object's bytes to
- * the HttpResponse's OutputStream. The object's class has to be on the
- * client's CLASSPATH.
- * </li>
- * <li>Relative HTTP URL <p/>
- * The destination is expected to write out a serialized object's bytes to
- * the HttpResponse's OutputStream. The object's class has to be on the
- * client's CLASSPATH.
- * </li>
- * <li><container-name>://<objectId><p/>
- * The object will be looked up in the specified container. If the object is
- * null a DataAccessException will be thrown.
- * </li>
- * <li><container-name>://<objectId>.<method-call> <p/>
- * The object will be looked up in the specified container; the method call
- * will be executed against the object. The RESULT of executing the method
- * should be an object and that is the object that will be wrapped
- * by this ObjectDataSource. If the container object or the result of the
- * method chain is NULL, a DataAccessException will be thrown.
- * </li>
- * </ul>
- *
- * <p/>
- *
- * The following attribute controls the refresh behavior of this datasource:
- *
- * <ul>
- * <li>refreshOnPropertyChange="true"|"false" <br/>
- * If the value of this attribute is "true", all datasource bindings will be
- * refreshed whenever a PropertyChangeEvent is fired within the source
- * Object. The default value is "true". <br/><br/>
- *
- * Note that in order for the automatic refresh to work, the Object creator
- * has to fulfill the following contract:<br/>
- * <ul>
- * <li>The Object must provide the following 2 methods for adding and removing
- * PropertyChangeListener objects: <br/><br/>
- * <ul>
- * <li>public void addPropertyChangeListener(PropertyChangeListener listener)
- * </li>
- * <li>public void removePropertyChangeListener(PropertyChangeListener listener)
- * </li>
- * </ul>
- * </li>
- * <li>It is the responsibility of the Object to manage its
- * PropertyChangeListeners and notify them when changes occur.
- * </li>
- * </ul>
- *
- * @author ikaplansky
- */
-
-
-
-/**
- * @constructor
- * Needs to be public since it could be used by reflection from the
- * ObjectDataSourceBridge class.
-**/
-ObjectDataSource = function () {
-// default no-args constructor
-};
-
-
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+**/
+Xap.provide("xap.data.datasource.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");
+Xap.require("google.xpath");
+
+
+
+xap.data.datasource.ObjectDataSource = function() {
+ xap.data.datasource.AbstractDataSource.call(this) ;
+};
+
Xap.setupClassAsSubclassOf("xap.data.datasource.ObjectDataSource", "xap.data.datasource.AbstractDataSource");
-//-----------------------------------------------------------------------
-// Instance variables.
-//-----------------------------------------------------------------------
-/**
- * @private PropertyChangeListener
-**/
-xap.data.datasource.ObjectDataSource.prototype._propertyChangeListener = null;
- // whether to refresh the datasource when the source object triggers
- // property change events.
+
/**
- * @private boolean
-**/
-xap.data.datasource.ObjectDataSource.prototype._refreshOnPropertyChange = true;
-
- //-----------------------------------------------------------------------
- // Constructors.
- //-----------------------------------------------------------------------
+ * Sets the source to be a document.
+ */
+xap.data.datasource.ObjectDataSource.prototype.setSource = function( object ) {
+ this.superclass.setSource.call(this, object );
-
+ //TODO this should be conditional?
+ this.refresh();
- //-----------------------------------------------------------------------
- // DataSource Interface.
- //-----------------------------------------------------------------------
-/**
- * @see DataSource#initialize(String, ClientSession, Element)
- *
- * @param id{String}
- * @param session{ClientSession}
- * @param element{XapElement}
- * @throws InitializationException
- * @public
- * @return {void}
-**/
-xap.data.datasource.ObjectDataSource.prototype.initialize = function (id, session, dataSourceElement) {
- xap.data.datasource.AbstractDataSource.prototype.initialize.call(this, id, session, dataSourceElement);
-};
-/**
- * First attempts to remove the PropertyChangeListener from the old source
- * object and then set it on the new object. Then the new object (data) is
- * set as this DataSource's source object.
- *
- * @param data{Object} the new datasource 'source' object
- *
- * @public
- * @return {void}
-**/
-xap.data.datasource.ObjectDataSource.prototype.setSource = function (data) {
- if (data == null) {
-// throw new IllegalArgumentException (
-// ResourceDictionary.getMessage(
-// NULL_SOURCE_MSGID,
-// AbstractDataSource.class,
-// this.getClass().getName()));
- throw new xap.util.Exception("ObjectDataSource.setSource: no data. ");
- }
- /*Object*/
- var oldSource = this.getSource();
- if (oldSource != null) {
- removePropertyChangeListener(oldSource, this.getPropertyChangeListener());
- }
- this.addPropertyChangeListener(data, this.getPropertyChangeListener());
- this.superclass.setSource.call(this, data);
- if (this.getRefreshOnPropertyChange()) {
- try {
- this.refresh();
- }
- catch (e) {
- /*DataAccessException, MalformedQueryException*/
- xap.data.datasource.ObjectDataSource.s_log.error(ex);
- }
- }
-};
-/**
- * Retrieves the source object from the specified sourceUrl and sets it on
- * this DataSource. The source object is retrieved either synchronously or
- * asynchronously depending on the type of the sourceUrl. If the sourceUrl
- * is an HTTP URL, the source is loaded asynchronously. If the sourceUrl is
- * a reference to a container object, the object is loaded synchronously.
- *
- * @param sourceUrl The url to the resource that is expected to contain or
- * produce the source object.
- *
- * @public
- * @param sourceUrl{String}
- * @return {void}
-**/
-xap.data.datasource.ObjectDataSource.prototype.loadObjectFromUrl = function (sourceUrl) {
- this.superclass.loadSourceFromServer.call(sourceUrl);
-};
-
-/**
- * @return the value of _refreshOnPropertyChange
- * @see #setRefreshOnPropertyChange(boolean)
- *
- * @public
- * @return {boolean}
-**/
-xap.data.datasource.ObjectDataSource.prototype.getRefreshOnPropertyChange = function () {
- return this._refreshOnPropertyChange;
-};
-/**
- * @return the source object for this ObjectDataSource
- *
- * @public
- * @return {Object}
-**/
-xap.data.datasource.ObjectDataSource.prototype.getObject = function () {
- return this.getSource();
+
};
- //-----------------------------------------------------------------------
- // Protected Methods.
- //-----------------------------------------------------------------------
-/**
- * @see AbstractDataSource#handleDataQuery( String, Context,
- * DataRetrievalListener )
- *
- * @protected
- * @param query{String}
- * @param context{Context}
- * @param listener{DataRetrievalListener}
- * @throws DataAccessException, MalformedQueryException
- * @return {void}
-**/
-xap.data.datasource.ObjectDataSource.prototype.handleDataQuery = function (query, context, listener) {
- /**
- * @
- Object
-**/
- xap.data.datasource.ObjectDataSource.prototype.contextObject
- = this.getSource();
- if (context != null) {
- contextObject = context.getData();
- }
- if (contextObject == null) {
- addPostponedQuery(query, context, listener);
- } else {
- /*Object*/
- var data = OgnlPath.evaluate(query, contextObject);
- listener.dataRetrieved(query, data, context);
- }
-};
-/**
- * @see AbstractDataSource#handleDataSetQuery( String, Context, * DataSetRetrievalListener )
- *
- * @protected
- * @return {void}
- *
- * @param query{String}
- * @param context{Context}
- * @param listener{DataSetRetrievalListener }
- * @throws DataAccessException, MalformedQueryException
-**/
-xap.data.datasource.ObjectDataSource.prototype.handleDataSetQuery = function (query, context, listener) {
- /*Object*/
- var contextObject = this.getSource();
- if (context != null) {
- contextObject = context.getData();
- }
- if (contextObject == null) {
- this.addPostponedQuery(query, context, listener);
- } else {
- /*Object*/
- var data = OgnlPath.evaluate(query, contextObject);
- /*DataSet*/
- var dataset = xap.data.datasource.AbstractDataSet.getDataSet(query, this, data);
- listener.dataSetRetrieved(query, dataset, context);
- }
-};
-/**
- * Returns the PropertyChangeListener that will be set (if possible) on the
- * source object. The listener impl used here just calls refresh() on the
- * datasource whenever any property event fires.
- *
- * @return PropertyChangeListener to set on the source object.
- *
- * @protected
- * @return {PropertyChangeListener}
-**/
-xap.data.datasource.ObjectDataSource.prototype.getPropertyChangeListener = function () {
- return this._propertyChangeListener;
-};
+
+
+
+xap.data.datasource.ObjectDataSource.prototype.responseToDataSource = function(response){
+ var result = dj_eval( '(' + response.responseText + ')');
+ return result ;
+}
+
/**
- * Returns the NetServiceListener instance that will be called back when
- * the source object is loaded asynchronously using NetService.
- * @return NetServiceListener implementation
- *
- * @protected
- * @return {NetServiceListener}
-**/
-xap.data.datasource.ObjectDataSource.prototype.getSourceLoadRequestListener = function () {
- return new ObjectLoadRequestListener(this);
+ * Mozilla supports an eval() on object itself but IE does not. This normalizes the behavior
+ * against both browsers. Note that by doing this to run a string against an object you have to
+ * do something like 'this.employees' not just 'employees'
+ */
+xap.data.datasource.ObjectDataSource.prototype.evalOnObject = function( evalText, object){
+ if (!object._eval){
+ object._eval = function( text ){
+ return eval(text);
+ }
+ }
+ return object._eval(evalText);
+}
+
+//TODO move this to a base class?
+xap.data.datasource.ObjectDataSource.prototype.handleDataQuery = function(query, context, listener) {
+
+ if (!this.getSource()){
+ if (listener.getBindingType() == xap.data.controller.BindingType.ONE_TIME){
+ this.addPostponedQuery( query, context, listener );
+ }
+ }
+ else{
+ var rawData = this.executeQuery(context, query) ;
+ listener.dataRetrieved(query, rawData, context);
+ }
};
+
+//TODO move this to a base class?
+xap.data.datasource.ObjectDataSource.prototype.handleDataSetQuery = function(query, context, listener) {
- //-----------------------------------------------------------------------
- // Private Methods.
- //-----------------------------------------------------------------------
-/**
- * Looks up addPropertyChangeListener method in the object. If the object
- * has it, the specified listener is added by reflection.
- *
- * @param object
- * @param listener
- *
- * @private
- * @return {void}
- *
- * @param object{Object}
- * @param listener{PropertyChangeListener}
-**/
-xap.data.datasource.ObjectDataSource.prototype.addPropertyChangeListener = function (object, listener) {
- try {
- if (listener != null && object != null) {
- /*Class*/
- var c = object.getClass(); //TODO ?????? in js?
- /*Method*/
- var m = c["addPropertyChangeListener"];
- //); new Class[]{ PropertyChangeListener.class }
- if (m) {
- m.call(object, listener);
- }
- }
- }
- catch (e) { //NoSuchMethodException,SecurityException,IllegalAccessException,InvocationTargetException
- if (this.getLog().isDebug()) {
- this.getLog().exception(e);
- }
- this.getClientSession().handleException( e);
- }
-};
+ if (!this.getSource()){
+ if (listener.getBindingType() == xap.data.controller.BindingType.ONE_TIME){
+ this.addPostponedQuery( query, context, listener );
+ }
+
+ }
+ else{
+ theData = this.executeQuery(context, query) ;
+ var dataset = xap.data.datasource.AbstractDataSet.getDataSet(query, this, theData);
+ listener.dataSetRetrieved(query, dataset, context);
+ }
+};
+
+
+
/**
- * Looks up removePropertyChangeListener method in the object. If the object
- * has it, the specified listener is removed by reflection.
- *
- * @param object
- * @param listener
- *
- * @private
- * @return {void}
- *
- * @param object{Object}
- * @param listener{PropertyChangeListener}
-**/
-xap.data.datasource.ObjectDataSource.prototype.removePropertyChangeListener = function (object, listener) {
- try {
- if (object != null && listener != null) {
- /*Class*/
- var c = object ; //.getClass();
- /*Method*/
- var m = c["removePropertyChangeListener"];
- //new Class[]{ PropertyChangeListener.class });
- if (m != null) {
- m.call(object, listener);
- }
- }
- }
- catch (e) { //NoSuchMethodException,SecurityException,IllegalAccessException,InvocationTargetException
- if (this.getLog().isDebug()) {
- this.getLog().exception(e);
- }
- this.getClientSession().handleException(e);
- }
-};
-
+ * Execute query against a DOM
+ * @see handleDataQuery
+ * @see handleDataSetQuery
+**/
+xap.data.datasource.ObjectDataSource.prototype.executeQuery =function(context ,queryString){
+
+ var contextObject = this.getSource();
+ if (context){
+ contextObject = context.getData();
+ }
+
+ //eval query string relative to context object
+
+ return this.evalOnObject(queryString,contextObject);
+}
\ No newline at end of file