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/08/02 10:00:24 UTC

svn commit: r427946 - /incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js

Author: mturyn
Date: Wed Aug  2 03:00:23 2006
New Revision: 427946

URL: http://svn.apache.org/viewvc?rev=427946&view=rev
Log:
Replaced an eval() with a closure for algorithmic event-handler creation (peer.onFoo-->bridge.onFoo).

Modified:
    incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js

Modified: incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js?rev=427946&r1=427945&r2=427946&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js Wed Aug  2 03:00:23 2006
@@ -159,14 +159,23 @@
 }
 
 
+// Closure to create a default function---is there still a problem 
+// (memory leak) with this in IE?
+xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.getOnXFunction = function(str){
+	return function(){
+				return this.fireEvent(str) ;
+		 	} ;
+}
+
+
 /**
  *		Default behavior:  transfer all "onXXX" methods to the bridge:
- **/ 
- xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.onFuncMapper = new Object() ;
+**/ 
 xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.getEventTriggers = function () {
 	if(! this.eventTriggers ){
 		var triggerMap = new Object() ;
-		// Let's transfer all the "onXXX" methods over to the xal app:
+		// Let's transfer all the "onXXX" methods over to the bridge---first find
+		// them, then use a closure to create the new function:
 		for(var keyy in this._peer){
 			var member = this._peer[keyy] ;
 			if( !xap.bridges.basic.AbstractBlackBoxWidgetBridge.s_IsFunction(member) ){
@@ -179,7 +188,8 @@
 					// This is the only way I could think of (that worked) to
 					// get the name of the event into the callback definition, so
 					// "onBlur"  --> this.fireEvent("onBlur")
-					this[keyy] = eval(  this.getStringForFireEventMethodString(keyy)	) ;
+					this[keyy] = this.getOnXFunction(keyy) ;//this.eval(  this.getStringForFireEventMethodString(keyy)	) ;		
+				
 				}
 			}
 		}
@@ -188,13 +198,7 @@
 	return  this.eventTriggers ;
 };
 
-// "Evil, be thou my good."---Marlowe's "Faust"
-// In the lack of a robust context-passing mechanism,
-// this is the only way I could think of to get the name of
-// the event into the function:
-xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.getStringForFireEventMethodString = function(keyy){
-	return " function(){\n"
-				+"this.fireEvent(\""+keyy+"\") ;\n"
-				+"		}"
-}
+
+
+