You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/10/01 18:40:42 UTC

svn commit: r451782 - in /incubator/xap/trunk/WebContent/examples/dataBinding: Employees.js javascriptDatasource.html javascriptDatasource.xal

Author: mturyn
Date: Sun Oct  1 11:40:42 2006
New Revision: 451782

URL: http://svn.apache.org/viewvc?view=rev&rev=451782
Log:
MAde example look a bit more interesting to business people.

Added:
    incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js
Modified:
    incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html
    incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal

Added: incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js?view=auto&rev=451782
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js (added)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/Employees.js Sun Oct  1 11:40:42 2006
@@ -0,0 +1,61 @@
+Employees = function(){
+}
+
+Employees.Record = function(pLname, pFname, pId){
+	this.lname = pLname ;
+	this.fname = pFname ;
+	this.id = pId ;
+}
+
+Employees.Record.prototype = new Object ;
+Employees.Record.prototype.toString = function(){
+	return "["+this.id+":"+this.lname+","+this.fname+"]" ;
+}
+
+Employees.array = [
+	new Employees.Record("Last name","First name","i.d."),
+	new Employees.Record("Doe","John",Math.ceil(100*Math.random())),
+	new Employees.Record("Roe","Mary",Math.ceil(100*Math.random())),
+	new Employees.Record("Smith","Winston",Math.ceil(100*Math.random())),
+	new Employees.Record("O'Brien","Julia",Math.ceil(100*Math.random())),
+	new Employees.Record("Venture","Thaddeus",Math.ceil(100*Math.random())),
+	new Employees.Record("Savage","Danforth \"Doc\"",Math.ceil(100*Math.random())),
+	new Employees.Record("Brown","Jordan",Math.ceil(100*Math.random())),
+	new Employees.Record("Puneval","Theophilus",Math.ceil(100*Math.random()))
+] ;
+
+
+Employees.computeY= function(anIndex, offset){
+	if(!offset){
+		offset = 0 ;
+	}
+	return ""+(offset+((3+anIndex)*50))+"px" ;
+}
+
+Employees.prototype.second = function(){
+	return "The second slot in this array will give us: "
+			+Employees.array[1]+"." ;
+}
+
+
+
+Employees.prototype.theArray = function(){
+	return Employees.array ;
+}
+
+Employees.prototype.theVector = function(){
+	var vec = new xap.util.Vector(Employees.array.length,0) ;
+	for (var ii=0; ii<Employees.array.length; ++ii){
+		vec.addElement(Employees.array[ii]) ;
+	}
+	return vec ;
+}
+
+
+					
+							
+
+
+
+
+

Modified: incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html?view=diff&rev=451782&r1=451781&r2=451782
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.html Sun Oct  1 11:40:42 2006
@@ -17,7 +17,7 @@
 	</script>
 
 		<script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
-		<script language="JavaScript" type="text/javascript" src="AnArray.js"></script>
+		<script language="JavaScript" type="text/javascript" src="Employees.js"></script>
 
 <!--  
 Remove debugging in a final check, since debugging's 

Modified: incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal?view=diff&rev=451782&r1=451781&r2=451782
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dataBinding/javascriptDatasource.xal Sun Oct  1 11:40:42 2006
@@ -1,16 +1,10 @@
 <xal xmlns="http://www.openxal.org/xal" xmlns:xal="http://www.openxal.org/xal"> 
 
 
-	<mco:mco 
-		xmlns:mco="http://www.openxal.org/mco" 
-		id="anArray" 
-		src="AnArray"
-	/>
-	
 	<javascriptDataSource
 		xmlns="http://www.openxal.org/data"
 		id="myDataSource"
-		source="new AnArray()"
+		source="new Employees()"
 	/>	
 	
 	
@@ -29,17 +23,17 @@
 		
 			<xal:label 
 				id="topLabel"
-				width="660px" 
+				width="990px" 
 				height="40px"
 				backgroundColor="#b0a0b0"
 				alignHorizontal="center"						
-				text="Expressions using an object data source:"
+				text="Expressions using a JavaScript object data source:"
 			/>
 		
 			<xal:label 
 				y="50px"
 				x="25px"
-				width="290px" 
+				width="280px" 
 				height="40px"
 				alignHorizontal="center"
 				backgroundColor="#ddddff" 				
@@ -49,7 +43,7 @@
 			<xal:label 				
 				y="50px"
 				x="330px"			
-				width="290px" 			
+				width="590px" 			
 				height="40px"			
 				backgroundColor="#ffdddd"			
 				alignHorizontal="center"			
@@ -61,10 +55,9 @@
 				id="iterStartLabel"
 				y="100px"
 				x="0px"
-				width="660px" 
+				width="990px" 
 				height="40px"
-				backgroundColor="#b0a0b0"
-				alignHorizontal="center"						
+				backgroundColor="#b0a0b0"						
 				text="[iteration starts]"
 			/>
 		
@@ -78,7 +71,7 @@
 				>
 
 					<xal:label 
-						y="{*('AnArray.computeY(<currentElement>)')}"
+						y="{*('Employees.computeY(<currentIndex>)')}"
 						x="25px"			
 						width="290px" 			
 						height="40px"				
@@ -87,81 +80,45 @@
 						text="{*('&quot;Iteration &quot;+<currentCount>+&quot; of   &quot;+<totalCount>+&quot;.&quot;')}"
 					/>
 
+
 					<xal:label 
-						y="{*('AnArray.computeY(<currentElement>)')}"
+						y="{*('Employees.computeY(<currentIndex>)')}"
 						x="330px"			
 						width="290px" 			
 						height="40px"				
 						backgroundColor="#ffdddd" 
 						alignHorizontal="center" 
-						text="{*('<currentElement>')}"
+						text="{*('<currentElement>.id')}"
 					/>
-				</iterator>				
-
-				<xal:label 
-					id="iterStopLabel"
-					width="660px" 
-					height="40px"
-					y="550px"
-					backgroundColor="#b0a0b0"
-					textAlign="center"						
-					text="[iteration ends]"
-				/>	
-				
-				<xal:label 
-					id="iterStartLabel1"
-					width="660px" 
-					height="40px"
-					y="600px"
-					backgroundColor="#b0a0b0"
-					textAlign="center"						
-					text="[iteration begins again]"
-				/>						
-
-				<iterator 
-					xmlns="http://www.openxal.org/data" 
-					name="anIterator" 
-					dataSource="myDataSource" 
-					select="theArray()" 
-					type="ONE_WAY"
-				>
-
+					
 					<xal:label 
-						y="{*('AnArray.computeY(<currentElement>,520)')}"
-						x="25px"			
+						y="{*('Employees.computeY(<currentIndex>)')}"
+						x="655px"			
 						width="290px" 			
 						height="40px"				
 						backgroundColor="#ddffdd" 
-						alignHorizontal="center" 
-						text="{*('&quot;Iteration &quot;+<currentCount>+&quot; of   &quot;+<totalCount>+&quot;.&quot;')}"
-					/>
-
-					<xal:label 
-						y="{*('AnArray.computeY(<currentElement>,520)')}"
-						x="330px"			
-						width="290px" 			
-						height="40px"				
-						backgroundColor="#dddddd" 
-						alignHorizontal="center" 
-						text="{*('<currentElement>')}"
-					/>
-				</iterator>
+						alignHorizontal="left" 
+						text="{*('&quot;. . . &quot;+<currentElement>.lname+&quot;, &quot;+<currentElement>.fname')}"
+					/>					
+					
+				</iterator>				
 
 				<xal:label 
-					id="iterStopLabel1"
-					width="660px" 
+					id="iterStopLabel"
+					width="990px" 
 					height="40px"
-					y="1100px"
+					y="600px"
 					backgroundColor="#b0a0b0"
 					textAlign="center"						
-					text="[second iteration ends]"
-				/>					
+					text="[iteration ends]"
+				/>	
+								
 				
 		</freePanel>
 		
 		<!--  Didn't display after freePanel's end...why not?  xal:label 
 			id="iterStopLabel"
-			width="660px" 
+			width="990px" 
 			height="40px"
 			backgroundColor="#b0a0b0"
 			textAlign="center"