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/07/25 22:23:46 UTC

svn commit: r425539 - in /incubator/xap/trunk: WebContent/examples/dojo/ src/xap/bridges/dojo/

Author: mturyn
Date: Tue Jul 25 15:23:45 2006
New Revision: 425539

URL: http://svn.apache.org/viewvc?rev=425539&view=rev
Log:
Hooked up Dojo Widgets (buttons, so far) to the XAP event-handling scheme; the meat of the change is in xap.brdiges.dojo.DojoWidgetBridge.createPeer(), near the end of that method, where we use Dojo's "connect" method to hook up our <bridge>.fireEvent() to a DOM event ("onclick" in the case of buttons).

Added:
    incubator/xap/trunk/WebContent/examples/dojo/dojo1Handler.js   (with props)
Modified:
    incubator/xap/trunk/WebContent/examples/dojo/dojo1.html
    incubator/xap/trunk/WebContent/examples/dojo/dojo1.js
    incubator/xap/trunk/WebContent/examples/dojo/dojo1.xal
    incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js

Modified: incubator/xap/trunk/WebContent/examples/dojo/dojo1.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/dojo1.html?rev=425539&r1=425538&r2=425539&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/dojo1.html (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/dojo1.html Tue Jul 25 15:23:45 2006
@@ -23,14 +23,15 @@
 
     <script language="JavaScript" type="text/javascript">    	
 		Xap.addDebuggables( 
-						"xap.bridges.dojo.DojoButtonBridge",
 						"xap.taghandling.AbstractTagImpl",
-						"xap.bridges.dojo.DojoWidgetBridge"
+						"xap.bridges.dojo.DojoWidgetBridge",		
+						"xap.bridges.dojo.DojoButtonBridge"
+
 							) ;
     </script>
    
     <script language="JavaScript" type="text/javascript">
-    	Xap.bootstrap( "../../", "debugAll");
+    	Xap.bootstrap( "../../", "debugAll" );
   	</script>
 
     	
@@ -47,11 +48,12 @@
  	</script>
 
 	<script language="JavaScript" src="dojo1.js"> </script>
+	<script language="JavaScript" src="dojo1Handler.js"> </script>	
 	
  </head>
  
 
-<body onLoad="Xap.scanPage();if(document.showStatus){document.showStatus();}">
+<body onLoad="Xap.scanPage();if(xap.showStatus){xap.showStatus();}">
 	<script type="text/javascript">
 		DBG = new AjxDebug( AjxDebug.NONE, null, false ); 
 	</script>
@@ -78,6 +80,7 @@
 	<button onclick="alert(MyApp.getDocumentContainer().getUiDocument().toXml());">hello</button>
 	<div id="foot">FOOTER TEXT</dev>
 
-
+<!--  Do this as late as possible---brings in script tags: -->
+<script> Xap._loadDebuggables() </script>
 </body>
 </html>

Modified: incubator/xap/trunk/WebContent/examples/dojo/dojo1.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/dojo1.js?rev=425539&r1=425538&r2=425539&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/dojo1.js (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/dojo1.js Tue Jul 25 15:23:45 2006
@@ -1,4 +1,4 @@
-document.showStatus = function(){
+xap.showStatus = function(){
 	var session = window["MyApp"] ;
 
 	var node = session.domContainer ;
@@ -35,4 +35,7 @@
 						+ "<code>"+path +"</code>"
 							;
 }	
+
+
+
 		

Modified: incubator/xap/trunk/WebContent/examples/dojo/dojo1.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/dojo1.xal?rev=425539&r1=425538&r2=425539&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/dojo1.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/dojo1.xal Tue Jul 25 15:23:45 2006
@@ -1,16 +1,28 @@
 <xal xmlns="http://www.openxal.org/xal"> 
+
+
+	<mco:mco 
+		xmlns:mco="http://www.openxal.org/mco" 
+		id="handler" 
+		src="dojo1Handler"
+	/>
+
+
+
   <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
     <xm:append select="/xal">
-		<button xmlns="http://www.dojotoolkit.org/" text="New" 	
+		<button xmlns="http://www.dojotoolkit.org/" 
+			text="new" 	
 			color="#aa0000"
 			id="button0"
 			backgroundColor="#00aaaa"
+			onCommand="mco:handler.onClick(this)"
 		/> 
 		
    	</xm:append>
    	<!-- Try out caption-changing:  -->
 		<xm:set-attribute select="id('button0')">			
-			<attribute name="text" value="First..."/>
+			<attribute name="text" value="altered at start-up"/>
 		</xm:set-attribute>   	 
    	
    	

Added: incubator/xap/trunk/WebContent/examples/dojo/dojo1Handler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/dojo1Handler.js?rev=425539&view=auto
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/dojo1Handler.js (added)
+++ incubator/xap/trunk/WebContent/examples/dojo/dojo1Handler.js Tue Jul 25 15:23:45 2006
@@ -0,0 +1,38 @@
+// For MCO:
+function dojo1Handler() { }
+
+dojo1Handler.prototype = new Object() ;
+
+
+dojo1Handler.colours = ["<font color='#660000'>",
+						"<font color='#0000aa'>",
+						"<font color='#000000'>"
+						];						
+							
+dojo1Handler.prototype.onClick = function (srcNode) {
+//xap.util.Utils.interrogate(srcNode) ;
+	var attributes = srcNode.attributes;
+	
+	var i0 = Math.floor(3*Math.random() );
+	var i1 = (i0+1)%3 ;
+	var i2 = (i0+2)%3 ;
+
+	var resultString = "<br/><br/>"+dojo1Handler.colours[i0]
+						+"An MCO call got the attributes of the XAP button: " ;
+	if(!attributes){
+		resultString += "<br/><NONE>" ;
+	} else {
+		for (var ii = 0; ii <attributes.length; ++ii ){
+			resultString +="<br/>&nbsp;&nbsp;&nbsp;&nbsp;"
+							+ dojo1Handler.colours[i1]
+							+attributes[ii].nodeName
+							+"</font>" ;
+			resultString +=":"+ dojo1Handler.colours[i2]
+								+attributes[ii].nodeValue+"</font>" ;				
+		}
+	}
+	xap.showStatus() ;
+	var ticker = document.getElementById("xapStat") ;
+	ticker.innerHTML = ticker.innerHTML + resultString ;
+	
+}
\ No newline at end of file

Propchange: incubator/xap/trunk/WebContent/examples/dojo/dojo1Handler.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js?rev=425539&r1=425538&r2=425539&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js Tue Jul 25 15:23:45 2006
@@ -102,11 +102,12 @@
           peer.activeImg=value ;
     }
     else if (name=="onClick"){
-        dojo.event.connect(peer, 'onClick', value)
+        dojo.event.connect(peer, 'onClick', value) ;
     }
-    else if (name=="onCommand"){
-        dojo.event.connect(peer, 'onCommand', value)
-    }    
+//    else if (name=="onCommand"){
+//        //dojo.event.connect(peer.domNode, 'onCommand', value) ;
+//		document.addEventListener("onclick", this._onSelectEvent, this);        
+//    }    
     else{
         xap.bridges.dojo.DojoWidgetBridge.prototype.attributeSet.call( this, event );
     }
@@ -168,4 +169,17 @@
  	return map ;
  }
  
+ 
+
+
+/**
+ * With what event will we associate our top-level "fireEvent" which
+ * will turn into a direct Javascript eval, and MCO, a Macro, and http: request.... ?
+**/ 
+xap.bridges.dojo.DojoButtonBridge.prototype.getEventAttachString = function(){
+	return "onclick" ;
+}
+
+
+
  

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js?rev=425539&r1=425538&r2=425539&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Tue Jul 25 15:23:45 2006
@@ -97,7 +97,7 @@
 	return xap.util.ArrayHelper.indexOf(this.getAllowedInitialProperties(),prop)>-1 ;
 }
 
-/**
+ /**
  * 
  * Since the <code>dojo.widget.createWidget()</code> 
  * is good at creating a widget into the place in a DOM previously 
@@ -165,15 +165,13 @@
    
    		// The candy in the middle of the wrapper:
    		//xap.util.Utils.interrogate(propertyMap) ;
-        var peer = dojo.widget.createWidget(dojoType,propertyMap,tmp);
-   
+        var peer = dojo.widget.createWidget(dojoType,propertyMap,tmp); 
 		this.setPeer( peer );
-		//peer.addSelectionListener(new AjxListener(this, this._onSelectEvent));
+		dojo.event.connect(peer.domNode,this.getEventAttachString(), this,"_onSelectEvent"); 				
 	} else {
 		xap.bridges.dojo.DojoWidgetBridge.s_log.error("Bogus parent peer:" + parentPeer );
 	}
 }
-