incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r454553 - in /incubator/xap/trunk: WebContent/examples/dataBinding/ src/xap/data/bridge/ src/xap/data/controller/ src/xap/data/datasource/ src/xap/data/formatter/ src/xap/taghandling/
Date Mon, 09 Oct 2006 23:27:52 GMT
Author: mturyn
Date: Mon Oct  9 16:27:52 2006
New Revision: 454553

URL: http://svn.apache.org/viewvc?view=rev&rev=454553
Log:
Added MessageFormatterBridge, examples using it, and examples using the bind('select=...;formatter=...')
syntax.

Added:
    incubator/xap/trunk/WebContent/examples/dataBinding/EmployeesArrays_json.js
    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/src/xap/data/bridge/MessageFormatterBridge.js
    incubator/xap/trunk/src/xap/data/formatter/MessageFormatter.js
Modified:
    incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal
    incubator/xap/trunk/src/xap/data/bridge/DecimalFormatterBridge.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/ObjectDataSourceBridge.js
    incubator/xap/trunk/src/xap/data/controller/Binding.js
    incubator/xap/trunk/src/xap/data/controller/ContextStack.js
    incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js
    incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js
    incubator/xap/trunk/src/xap/taghandling/plugin.xml

Added: incubator/xap/trunk/WebContent/examples/dataBinding/EmployeesArrays_json.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/EmployeesArrays_json.js?view=auto&rev=454553
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/EmployeesArrays_json.js (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/EmployeesArrays_json.js Mon Oct  9
16:27:52 2006
@@ -0,0 +1,24 @@
+
+// Used to test the use of message formats:
+var employees = { 
+	"arrays":[
+		["Jeanne","Doe","3791"],
+		["zero","one","two","three","four","five","six"],		
+		["Mary","Roe","1788"],
+		["Ameesh","Chakravarti","1317"],
+		["Arne","Sachnussen","9128"],
+		["Manny","Fein","1940"],
+		["Vipul","Periwal","3743"],
+		["Xiuxiu","Guo","6742"],
+		["Burt","Ernesson","8045"],
+		["John","Kellogg","7091","Hodgman"],
+		["Larry","Bendix","3183"],
+		["Daryl","Bendix","6667","Briand"],
+		["Larry","Bendix","3742"],
+		["Bob","Dobson","3166"],
+		["Jean","Poole","1138"],
+		["Nozomi","Takahashi","0023"],
+		["Deanne","Ilium","2171"]
+	]
+} ;
+

Modified: incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal?view=diff&rev=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/jsonDatasource.xal Mon Oct  9 16:27:52
2006
@@ -60,7 +60,7 @@
 				-->
 					<xal:cell text="{*('id')}" textAlign="right" fontFamily="Garamond" fontSize="11pt"/>
	
 					<xal:cell text="{*('lname')}" fontFamily="Garamond" fontSize="11pt"/>
-					<xal:cell text="{*('fname')}" fontFamily="Garamond" fontSize="11pt"/>		
+					<xal:cell text="{*('fname')}" fontFamily="Garamond" fontSize="11pt"/>
 				</xal:row>	
 						
 			</iterator>

Added: incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.html?view=auto&rev=454553
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.html (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.html Mon Oct  9 16:27:52
2006
@@ -0,0 +1,83 @@
+<html>
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+		<title>
+				Testing messageFormatter tag 
+				whilst iterating over records 
+				from a JSON 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>

+
+<!--  
+Remove debugging in a final check, since debugging's 
+alternate loading method (using <script/> tags) can
+mask forgetting a .require(<className>) in the code:
+-->
+
+    <script language="JavaScript" type="text/javascript">
+    	Xap._sourceRootDir = "../../" ; 	
+		Xap.addDebuggables(		
+							"xap.data.DataFramework",
+							"xap.data.DataServiceFactory",
+							"xap.data.DataServiceImpl",
+							"xap.data.bridge.DataAttributeConverter",
+							"xap.data.bridge.DataFrameworkBridge",
+							"xap.data.bridge.DataSourceBridge",
+							"xap.data.bridge.FormatterBridge",
+							"xap.data.bridge.JavascriptDataSourceBridge",
+							"xap.data.bridge.JsonDataSourceBridge",														
+							"xap.data.bridge.ObjectDataSourceBridge",
+							"xap.data.controller.ContextFrame",		
+							"xap.data.controller.Iterator",
+							"xap.data.controller.Binding",							
+							"xap.data.datasource.AbstractDataSet",
+							"xap.data.datasource.AbstractDataSource",							
+							"xap.data.datasource.ArrayDataSet",
+							"xap.data.datasource.DataSetFactory",						
+							"xap.data.datasource.DataSourceContainerImpl",
+							"xap.data.datasource.DataSourceImpl",
+							"xap.data.datasource.JavascriptDataSource",
+							"xap.data.datasource.JsonDataSource",							
+							"xap.data.datasource.SimpleDocumentDataSource",							
+							"xap.data.formatter.MessageFormatter",
+							"xap.resolver.AttributeResolutionHandler",
+							"xap.session.ClientSession",
+							"xap.session.DeclarativeArgumentParser",
+							"xap.taghandling.AbstractTagImpl",							
+							"xap.taghandling.AttributeConverter",
+							"xap.util.MessageFormat",
+							"xap.xml.dom.Document"
+																						
+							) ;
+		Xap._loadDebuggables() ;
+	</script>	
+	
+	<!--Needed for the mco tag in the xal file:  -->
+	<script language="JavaScript" src="Layout.js"> </script>						
+
+	</head>
+
+	<body onload="Xap.createAllPredefinedSessions();">
+		<h3>Testing messageFormatter on employee data from a JSON document:</h3>
+		<div style="left:100px;top:100px" xapId="MfmtExample" xapSrc="messageFormatter.xal"
xapToolkit="dojo" xapContext="../../"></div>
+		<div top="380px">
+			(see <a href="messageFormatter.xal">messageFormatter.xal</a>, <a href="EmployeesArrays_json.js">EmployeesArrays_json.js</a>.)
+		</div>		
+	</body>
+</html>

Added: incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.xal?view=auto&rev=454553
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.xal (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter.xal Mon Oct  9 16:27:52
2006
@@ -0,0 +1,96 @@
+<xal 
+	xmlns="http://www.openxal.org/xal" 
+	xmlns:xal="http://www.openxal.org/xal"
+	xmlns:data="http://www.openxal.org/data"
+	xmlns:xm="http://www.openxal.org/xmodify"	
+>
+
+	<jsonDataSource
+		xmlns="http://www.openxal.org/data"
+		id="employees"
+		path="EmployeesArrays_json.js"
+		source="employees"
+	/>	
+	
+
+	<data:messageFormatter 
+		id="fmtTheLabelString" 
+		format="arg 1:'{1}', arg 0:'{0}', arg 2:'{2}', arg 6:'{6}', arg 5:'{5}', arg 4:'{4}', arg
3:'{3}'."
+	/>
+
+	<data:binding 
+		xmlns="http://www.openxal.org/data" 
+		dataSource="employees" 
+		select="arrays" 
+		id="employeesArray"
+	/>
+	
+	<data:binding 
+		xmlns="http://www.openxal.org/data" 
+		dataSource="employees" 
+		select="arrays[1]" 
+		id="second"
+	/>
+	
+	<data:binding 
+		xmlns="http://www.openxal.org/data" 
+		dataSource="employees" 
+		select="arrays[1]" 
+		id="secondFormatted"
+		formatter="fmtTheLabelString"
+	/>	
+
+		
+	
+	
+	<xm:modifications>
+		<xm:append select="/xal">
+			<table width="100%" height="140px" borderStyle="dashed" borderWidth="1px">
+				<row>
+					<cell text="Data:" textAlign="left" fontSize="11pt"/>
+				</row>						
+				<row>
+					<cell text="{bind(binding:second)}" 
+						fontSize="12pt"					
+					/>
+				</row>
+				<row>
+					<cell text="Format string:" textAlign="left" fontSize="11pt"/>
+				</row>				
+				<row>
+					<cell text="arg 1:'{1}', arg 0:'{0}', arg 2:'{2}', arg 6:'{6}', arg 5:'{5}', arg
4:'{4}', arg 3:'{3}'."
+						fontSize="12pt"		
+					/>
+				</row>
+				<row>
+					<cell text="Result:" textAlign="left" fontSize="11pt"/>
+				</row>									
+				<row>
+					<cell text="{bind(binding:secondFormatted)}" 
+						fontSize="13pt"					
+					/>
+				</row>				
+			</table>
+
+			<table>
+			<!-- Iterator -->
+				<data:iterator 
+						name="anIterator" 
+						dataSource="employees" 
+						select="arrays" 
+						type="ONE_WAY"
+						formatter="fmtTheLabelString"
+				>
+					<row>
+						<cell text="{*('')}"/>
+					</row>
+	
+				</data:iterator>
+			</table>
+
+
+
+
+		</xm:append>
+	</xm:modifications>
+</xal>

Added: incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.html?view=auto&rev=454553
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.html (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.html Mon
Oct  9 16:27:52 2006
@@ -0,0 +1,86 @@
+<html>
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+		<title>
+				Testing the bind('select=...;formatter=...')
+				syntax with the messageFormatter tag
+ 				and a JSON 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>

+
+<!--  
+Remove debugging in a final check, since debugging's 
+alternate loading method (using <script/> tags) can
+mask forgetting a .require(<className>) in the code:
+-->
+
+    <!--  script language="JavaScript" type="text/javascript">
+    	Xap._sourceRootDir = "../../" ; 	
+		Xap.addDebuggables(		
+							"xap.data.DataFramework",
+							"xap.data.DataServiceFactory",
+							"xap.data.DataServiceImpl",
+							"xap.data.bridge.DataAttributeConverter",
+							"xap.data.bridge.DataFrameworkBridge",
+							"xap.data.bridge.DataSourceBridge",
+							"xap.data.bridge.FormatterBridge",
+							"xap.data.bridge.JavascriptDataSourceBridge",
+							"xap.data.bridge.JsonDataSourceBridge",														
+							"xap.data.bridge.ObjectDataSourceBridge",
+							"xap.data.controller.ContextFrame",		
+							"xap.data.controller.Iterator",
+							"xap.data.controller.Binding",							
+							"xap.data.datasource.AbstractDataSet",
+							"xap.data.datasource.AbstractDataSource",							
+							"xap.data.datasource.ArrayDataSet",
+							"xap.data.datasource.DataSetFactory",						
+							"xap.data.datasource.DataSourceContainerImpl",
+							"xap.data.datasource.DataSourceImpl",
+							"xap.data.datasource.JavascriptDataSource",
+							"xap.data.datasource.JsonDataSource",							
+							"xap.data.datasource.SimpleDocumentDataSource",							
+							"xap.data.formatter.MessageFormatter",
+							"xap.resolver.AttributeResolutionHandler",
+							"xap.session.ClientSession",
+							"xap.session.DeclarativeArgumentParser",
+							"xap.taghandling.AbstractTagImpl",							
+							"xap.taghandling.AttributeConverter",
+							"xap.util.MessageFormat",
+							"xap.xml.dom.Document"
+																						
+							) ;
+		Xap._loadDebuggables() ;
+	</script  -->	
+	
+	<!--Needed for the mco tag in the xal file:  -->
+	<script language="JavaScript" src="Layout.js"> </script>						
+
+	</head>
+
+	<body onload="Xap.createAllPredefinedSessions();">
+		<h3>Testing messageFormatter and the <br/>
+			<code><font size="+1">bind('select=...;formatter=...')</font></code><br/>
+			syntax on data from a JSON document:</h3>
+		<div style="left:100px;top:100px" xapId="Mfmt_altExample" xapSrc="messageFormatter_altSyntax.xal"
xapToolkit="dojo" xapContext="../../"></div>
+		<div top="380px">
+			(see <a href="messageFormatter_altSyntax.xal">messageFormatter_altSyntax.xal</a>,
<a href="EmployeesArrays_json.js">EmployeesArrays_json.js</a>.)
+		</div>		
+	</body>
+</html>

Added: incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.xal?view=auto&rev=454553
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.xal (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/messageFormatter_altSyntax.xal Mon
Oct  9 16:27:52 2006
@@ -0,0 +1,69 @@
+<xal 
+	xmlns="http://www.openxal.org/xal" 
+	xmlns:xal="http://www.openxal.org/xal"
+	xmlns:data="http://www.openxal.org/data"
+	xmlns:xm="http://www.openxal.org/xmodify"	
+>
+
+	<jsonDataSource
+		xmlns="http://www.openxal.org/data"
+		id="employees"
+		path="EmployeesArrays_json.js"
+		source="employees"
+	/>
+	
+
+	<data:messageFormatter 
+		id="f_0" 
+		format="First: {0}"
+	/>
+	<data:messageFormatter 
+		id="f_1" 
+		format="last: {1}"
+	/>
+	<data:messageFormatter 
+		id="f_2" 
+		format="id: {2}"
+	/>		
+
+	<data:binding 
+		xmlns="http://www.openxal.org/data" 
+		dataSource="employees" 
+		select="arrays" 
+		id="employeesArray"
+	/>
+	
+		
+	
+	
+	<xm:modifications>
+		<xm:append select="/xal">
+			<table>
+			<!-- Iterator -->
+				<data:iterator 
+						name="anIterator" 
+						dataSource="employees" 
+						select="arrays" 
+						type="ONE_WAY"
+				>
+ 					<row>
+						<cell text="{bind('select=')}"/>
+					</row>
+					<row>
+						<cell text="{bind('select=;formatter=f_0')}"/>
+						<cell text="{bind('select=;formatter=f_1')}"/>
+						<cell text=". . . "/>						
+						<cell text="{bind('select=;formatter=f_2')}" width="60px" textAlign="right"/>
											
+					</row>
+ 					<row>
+						<cell height="25px"/>
+					</row>					
+				</data:iterator>
+			</table>
+
+
+
+
+		</xm:append>
+	</xm:modifications>
+</xal>

Modified: incubator/xap/trunk/src/xap/data/bridge/DecimalFormatterBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DecimalFormatterBridge.js?view=diff&rev=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DecimalFormatterBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DecimalFormatterBridge.js Mon Oct  9 16:27:52
2006
@@ -53,19 +53,9 @@
 	/*DecimalFormatter*/
 	var formatter = null;
 	try {
-//			if ( className != null &&
-//				 className.trim().length() != 0 ) {
-//				formatter =
-//					xap.data.bridgeDataAttributeConverter.
-//						 toClassInstance( className, DecimalFormatter.class );
-//			} else {
-
 		formatter = new xap.data.formatter.DecimalFormatter();
-
-//			}
 	}
 	catch (e) { // AttributeConversionException
-	alert(e);
 		this.reportInvalidXmlException(xap.data.bridge.XmlDataTokens.CLASS, "decimal formatter",
this.getElement(), e);
 	}
 	return formatter;

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=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/FormatterBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/FormatterBridge.js Mon Oct  9 16:27:52 2006
@@ -119,9 +119,8 @@
 	var className = this.getElement().getAttribute(xap.xml.XmlDataTokens.CLASS);
 	/*Formatter*/
 	var formatter = null;
-	try {
-//	formatter = xap.data.bridge.DataAttributeConverter.toClassInstance(
-//									  className, Formatter.class );
+	try {	
+//		formatter = eval( "new "+className + () ) ;
 		return formatter;
 	}
 	catch (e) { // AttributeConversionException

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=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/FormatterChainBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/FormatterChainBridge.js Mon Oct  9 16:27:52 2006
@@ -56,7 +56,7 @@
 	var formatter = null;
 	try {
 //			if ( className != null &&
-//				 className.trim().length() != 0 ) {
+//				 className.trim().length != 0 ) {
 //				 formatter = xap.data.bridge.DataAttributeConverter.toClassInstance(className, FormatterChain.class
);
 //
 //			} else {

Added: incubator/xap/trunk/src/xap/data/bridge/MessageFormatterBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/MessageFormatterBridge.js?view=auto&rev=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/MessageFormatterBridge.js (added)
+++ incubator/xap/trunk/src/xap/data/bridge/MessageFormatterBridge.js Mon Oct  9 16:27:52
2006
@@ -0,0 +1,89 @@
+/*
+ * 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.MessageFormatterBridge");
+Xap.require("xap.data.bridge.FormatterBridge");
+Xap.require("xap.taghandling.AttributeConversionException");
+Xap.require("xap.xml.InvalidXmlException"); 
+//Xap.require("xap.data.InitializationException") 
+Xap.require("xap.data.formatter.MessageFormatter");
+Xap.require("xap.data.formatter.JsFormatterImpl");
+
+Xap.require("xap.xml.XmlTokens");
+
+
+
+/**
+ * MessageFormatterBridge class handles the configuration element for a
+ * MessageFormatter instance.
+ *
+ * @author ikaplansky
+ */
+xap.data.bridge.MessageFormatterBridge = function () {
+	xap.data.bridge.FormatterBridge.call(this);
+};
+Xap.setupClassAsSubclassOf("xap.data.bridge.MessageFormatterBridge", "xap.data.bridge.FormatterBridge");
+	
+	//-----------------------------------------------------------------------
+	// Protected Methods.
+	//-----------------------------------------------------------------------
+/**
+ * @see FormatterBridge#createFormatter()
+ *
+ * @protected
+ * @return {Formatter}
+**/
+xap.data.bridge.MessageFormatterBridge.prototype.createFormatter = function () {
+	/*String*/
+	var className = this.getElement().getAttribute(xap.xml.XmlTokens.CLASS);
+
+	/*MessageFormatter*/
+	var formatter = null;
+	try {
+		formatter = new xap.data.formatter.MessageFormatter();
+	}
+	catch (e) { // AttributeConversionException
+		this.reportInvalidXmlException(xap.data.bridge.XmlDataTokens.CLASS, "decimal formatter",
this.getElement(), e);
+	}
+	return formatter;
+};
+/**
+ * @see FormatterBridge#initializeFormatter()
+ *
+ * @protected
+ * @return {void}
+ * @throws InitializationException
+**/
+xap.data.bridge.MessageFormatterBridge.prototype.initializeFormatter = function () {
+	xap.data.bridge.FormatterBridge.prototype.initializeFormatter.call(this);
+	try {
+		/*Locale*/
+		var locale = this.getLocale();
+		/*String*/
+		var format = this.getFormatPattern();
+		// TODO: Implement using the actual formatting object
+		// in the bridge class, not here---but implement it:
+		/*MessageFormat*/
+		//var theMessageFormat = new xap.data.formatter.MessageFormatter(format);
+		this.getFormatter().setFormat(format);
+	}
+	catch (e) { // InvalidXmlException
+//			throw new InitializationException(
+//					InitializationException.INVALID_XML_MSGID,
+//					MessageFormatterBridge.class.getName(), e );
+	}
+};
+

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=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js Mon Oct  9 16:27:52
2006
@@ -70,7 +70,7 @@
     var dataSource = null;
     try {
 //        if ( className != null && 
-//             className.trim().length() !=0 ) {
+//             className.trim().length !=0 ) {
 //            dataSource = /*(DataSource)*/ 
 //            	DataAttributeConverter.toClassInstance( className, ObjectDataSource );
 //        } else {
@@ -175,8 +175,8 @@
 **/
 xap.data.bridge.ObjectDataSourceBridge.prototype.setSource = function( dataSource, sourcePath
) {
     /*EventHandler*/
-    this.eventHandler = this.getSession().getEventHandler();
-    if ( this.sourcePath != null && sourcePath.trim().length() != 0 ) {
+    var eventHandler = this.getSession().getEventHandler();
+    if ( this.sourcePath != null && sourcePath.trim().length != 0 ) {
         /*String*/
         var objectUrl = eventHandler.qualifyObjectUrl( sourcePath );
         if ( objectUrl == null ) {

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=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/Binding.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/Binding.js Mon Oct  9 16:27:52 2006
@@ -96,7 +96,7 @@
 			this._select = select;
 			this._session = session;
 			this._bindingType = bindingType;
-			if (name != null && name.length() > 0) {
+			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

Modified: incubator/xap/trunk/src/xap/data/controller/ContextStack.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/ContextStack.js?view=diff&rev=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/ContextStack.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/ContextStack.js Mon Oct  9 16:27:52 2006
@@ -78,7 +78,7 @@
  * @param name{String}
 **/
 xap.data.controller.ContextStack.prototype.getContext = function (name) {
-	if (name == null || name.length() == 0) {
+	if (name == null || name.length == 0) {
 		return this.getCurrentContext();
 	}
 	for (var i = 0; i < this._contextStack.size(); i++) {

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=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js Mon Oct  9 16:27:52
2006
@@ -111,7 +111,10 @@
 	var theData = null;
 	// TODO:  do this right instead.  For the moment, all array
 	// return values are treated as part of an iteration:
-	//var theScript = contextObject+"."+query ;
+	//var theScript = contextObject+"."+query ;
+	if(!query){
+		query = "" ;
+	}
 	var theScript = this.constructor.resolveIteratorMacros(query);
 	// This basic JS data source evaluates the query as-is, not
 	// considering it as an operator on the source object.
@@ -158,7 +161,10 @@
 		contextObject = context.getData();
 	}
 	/*Object*/
-	var theData = null;
+	var theData = null;
+	if(!query){
+		query = "" ;
+	}	
 	var theScript = this.constructor.resolveIteratorMacros(query);
 	// This basic JS data source evaluates the query as-is, not
 	// considering it as an operator on the source object.

Modified: incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js?view=diff&rev=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js Mon Oct  9 16:27:52 2006
@@ -73,6 +73,9 @@
 	}
 	/*Object*/
 	var theData = null;
+	if(!query){
+		query = "" ;
+	}	
 	// TODO:  do this right instead.  For the moment, all array
 	// return values are treated as part of an iteration:
 	//var theScript = contextObject+"."+query ;
@@ -81,7 +84,13 @@
 	// source object is the base of all queries:
 	// 		<src_obj>.a_0()...a_n()
 	if( theScript.length>0){
-		theScript = "contextObject." + theScript;
+		// Unless this is an array op., e.g. 'select="[57]"'
+		// add the dot dereferencing ooperator which will act
+		// on the source:
+		if (theScript.trim()[0] != "[" ){
+			theScript = "."+theScript ;
+		}	
+		theScript = "contextObject" + theScript;
 		try {
 			theData = eval(theScript);
 		}
@@ -124,11 +133,20 @@
 	
 	/*Object*/
 	var theData = null;
+	if(!query){
+		query = "" ;
+	}	
 	var theScript = this.constructor.resolveIteratorMacros(query);
 	// This is a JSON bridge, the source object
 	// is the base of all queries:  <src_obj>.a_0()...a_n()
 	if(theScript.length>0){
-		theScript = "contextObject." + theScript;
+		// Unless this is an array op., e.g. 'select="[57]"'
+		// add the dot dereferencing ooperator which will act
+		// on the source:
+		if (theScript.trim()[0] != "[" ){
+			theScript = "."+theScript ;
+		}
+		theScript = "contextObject" + theScript;
 		try {
 			theData = eval(theScript);
 		}

Added: incubator/xap/trunk/src/xap/data/formatter/MessageFormatter.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/formatter/MessageFormatter.js?view=auto&rev=454553
==============================================================================
--- incubator/xap/trunk/src/xap/data/formatter/MessageFormatter.js (added)
+++ incubator/xap/trunk/src/xap/data/formatter/MessageFormatter.js Mon Oct  9 16:27:52 2006
@@ -0,0 +1,104 @@
+
+//Xap.require("xap.util.FormatUtils") ;
+//Xap.require("xap.util.Log") ;
+//Xap.require("xap.util.ResourceDictionary") ;
+/**
+ * MessageFormatter is used to format string messages.
+ * 
+ * <p/>
+ * Here is an example of declaring a MessageFormatter instance: <br/><br/>
+ * 
+ * &lt;messageFormatter xmlns="http://nexaweb.com/data" id="mf1" 
+ *   format="This is a message with a single Date: {0,date}"/&gt; <br/><br/>
+ * 
+ * The argument to the MessageFormatter is expected to be an Object[] where
+ * each Object is of the type expected by the format pattern (specified as the
+ * 'format' attribute in the messageFormatter element). If the argument is not
+ * an Object[], it will be converted into an Object[].  
+ * 
+ * <p/>
+ * In addition, this formatter will convert each Object in the Object[] into the 
+ * type expected by the underlying java's MessageFormat instance.  For example, 
+ * the formatter declared above could be called with a single String that 
+ * represents a Long and the MessageFormatter will convert it into an Object[] 
+ * of size 1 that has a Date object as its only element constructed with the
+ * passed in Long (the String will get converted into a Long object first).
+ * 
+ * @author ikaplansky
+ */
+Xap.provide("xap.data.formatter.MessageFormatter"); 
+
+// Superclass
+Xap.require("xap.data.formatter.JsFormatterImpl");
+// Peer
+Xap.require("xap.util.MessageFormat");
+
+//-----------------------------------------------------------------------
+// Constructors.
+//-----------------------------------------------------------------------
+xap.data.formatter.MessageFormatter = function () {
+	xap.data.formatter.JsFormatterImpl.call(this);
+};
+Xap.setupClassAsSubclassOf("xap.data.formatter.MessageFormatter", "xap.data.formatter.JsFormatterImpl");
+
+	//-----------------------------------------------------------------------
+	// Constants.
+	//-----------------------------------------------------------------------
+/*private static final String*/
+xap.data.formatter.MessageFormatter.ATTEMPT_AGRESSIVE_CONVERSION_MSGID = "attemptAggressiveConversion";
+
+
+	
+	//-----------------------------------------------------------------------
+	// Public Methods.
+	//-----------------------------------------------------------------------
+/**
+ * @return the underlying java.text.MessageFormat object used by 
+ * this formatter.
+ *
+ * @public
+ * @return {MessageFormat}
+**/
+xap.data.formatter.MessageFormatter.prototype.getMessageFormat = function () {
+	return /*(MessageFormat)*/
+	this.getFormat();
+};
+	
+	//-----------------------------------------------------------------------
+	// Protected Methods.
+	//-----------------------------------------------------------------------
+/**
+ * @see AbstractJavaFormatter#formatObject 
+ *
+ * @protected
+ * @return {Object}
+ *
+ * @param object{Object}
+ * @throws FormatException  
+**/
+xap.data.formatter.MessageFormatter.prototype.formatObject = function (object) {
+	var result = null ;
+	try {
+		var formatStr = this.getFormat();
+		result = xap.data.formatter.MessageFormatter.format(object, formatStr);
+	}
+	catch (e) { // IllegalArgumentException
+		this.constructor.s_log.error("MessageFormatter.formatObject: \n" + e);
+		throw e;
+	}
+	return result ;
+};
+xap.data.formatter.MessageFormatter.format = function (obj, fmtStr) {
+	var arrObj = null;
+	if (typeof obj == "object" && typeof obj.length != "undefined") {
+		arrObj = new Array(obj.length);
+		for (var j = 0; j < obj.length; ++j) {
+			arrObj[j] = obj[j];
+		}
+	} else {
+		arrObj = [("" + obj)];
+	}
+	var result = xap.util.MessageFormat.format(fmtStr, arrObj);
+	return result;
+};
+

Modified: incubator/xap/trunk/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/plugin.xml?view=diff&rev=454553&r1=454552&r2=454553
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Mon Oct  9 16:27:52 2006
@@ -27,10 +27,15 @@
 	
 	<!-- mappings that apply to the document named "formatters" -->
 	<tag-mappings namespace="http://www.openxal.org/data" document="formatters">
-		<mapping class="xap.data.bridge.FormatterBridge"
-			name="formatter"/>
-		<mapping class="xap.data.bridge.DecimalFormatterBridge"
-			name="decimalFormatter"/>			
+		<mapping name="formatter"
+			class="xap.data.bridge.FormatterBridge"
+		/>
+		<mapping name="decimalFormatter"
+			class="xap.data.bridge.DecimalFormatterBridge"
+		/>			
+		<mapping name="messageFormatter"
+			class="xap.data.bridge.MessageFormatterBridge"
+		/>				
 	</tag-mappings>
 	
 	



Mime
View raw message