incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r419686 - /incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
Date Thu, 06 Jul 2006 19:59:55 GMT
Author: mturyn
Date: Thu Jul  6 12:59:55 2006
New Revision: 419686

URL: http://svn.apache.org/viewvc?rev=419686&view=rev
Log:
Fixed small errors, added filtering so that attributes set on creation aren't needlessly reset
later.

Modified:
    incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js

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=419686&r1=419685&r2=419686&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Thu Jul  6 12:59:55 2006
@@ -20,8 +20,8 @@
  /**
  * @fileoverview
  * 
- * A bridge class that controls a generic dojo widget's peer; here
- * for now as an abstract superclass.
+ * A superclass for the bridges controlling a dojo widget peer; treat it
+ * as an abstract superclass.
  */
  
  
@@ -135,16 +135,19 @@
    		// (by default, widget i.d. === xap i.d.)
    		// This method should be spun off into an overridden
    		// getPropertyMap that can be widget-specific:
-        var propertyMap = {widgetId:this.getElement().getAttribute("id"),
-        					position:"absolute", title:"TO DO: working 'setTitle()' method"
+        var propertyMap = {widgetId:this.getElement().getAttribute("id")
         					} ;  
         			
         			
 
-   		// Allow us to create the object with attributes in place:
-   		// TO DO: An Atributes object with toArray() and toObject() methods:
-   		var arrAttr = this.getElement().attributes ;        					
-        this.mapAllowedInitialPropertiesFromXalToDojo(propertyMap, arrAttr) ;           

+		// map xal attributes to widget attributes, where possible;
+		// when last parameter is extant and "true", remove the
+		// attributes we're going to handle here from the xal attributes,
+		// which will be applied to the object after its creation:
+        this.mapAllowedInitialPropertiesFromXalToDojo(propertyMap, 
+        												this.getElement(),
+        												true            	
+        											) ;            
 
    		//alert(propertyMap.title) ;
    		// Forbid changing the dojoType if we're in a subclass and "already got one":
@@ -154,7 +157,7 @@
 		} else {
 			dojoType = propertyMap.dojoType ;
 		}
-		delete propertyMap.dojoType		
+		delete propertyMap.dojoType ;		
 
 		if (dojoType == null ){
 		// Make this a XapException once we're stable:
@@ -303,9 +306,17 @@
  *  combining this with setAttributes, or rather letting setAttributes
  *  use this:
  *  @param propertyMap A JS object holding name/value pairs
- *  @param arrAttributes---an array of attribute nodes produced by the parser/handler
+ *  @param holder An object holding an array of attribute nodes (in an "attributes" member)

+ *                produced by the parser/handler.
+ *  @param trimP  If there and true, trim allowed initial attributes from the 
+ *                attributes list so that they're not handled twice.
 **/ 
-DojoWidgetBridge.prototype.mapAllowedInitialPropertiesFromXalToDojo = function(propertyMap,arrAttributes){
+DojoWidgetBridge.prototype.mapAllowedInitialPropertiesFromXalToDojo = function(propertyMap,attrHolder,trimP){
+	var arrAttributes = attrHolder.attributes
+	// if trimP, all attributes we handle here will be
+	// removed from the list--easisest to just start a new list from scratch
+	// and append all the ones we'll want to keep there
+	var postInitAttributes = [] ;
 	//Doesn't do much here, but in subclasses:			
 	var mapper = this.getXalToToolkitMapper() ;
 	if(arrAttributes){
@@ -316,22 +327,29 @@
 			if (mapper[xalName]){
 				name = mapper[xalName] ;
 			}
-			// What about the value?  If necessary we could introduce 
-			// an object holding a map-to name and a callback used
-			// to get the right value....
-			var xalValue = arrAttributes[ii].nodeValue ;
-			//...but we'll just do a little bit here:
-			var value = xalValue ;
-			if (xalValue == "true"){
-				value = true ;
-			} else if (xalValue == "false"){
-				value = false ;
-			}
 			//Doesn't do much here, but for subclasses:
 			if( this.allowsInitialProperty(name)){
-				propertyMap[name] = value ;
-			}    		
-   		}
+				// What about the value?  If necessary we could introduce 
+				// an object holding a map-to name and a callback used
+				// to get the right value....
+				var xalValue = arrAttributes[ii].nodeValue ;
+				//...but we'll just do a little bit here:
+				var value = xalValue ;
+				if (xalValue == "true"){
+					value = true ;
+				} else if (xalValue == "false"){
+					value = false ;
+				}
+				propertyMap[name] = value ;				
+			} else if (trimP){
+				postInitAttributes.push( arrAttributes[ii] ) ;
+			}  		
+   		} // end iteration over attributes
+   	} // end gate over attributes' existing in the first place
+
+   	// If we want to trim the list of the attributes we've added to the property map:
+   	if( trimP ){
+   		attrHolder.attributes = postInitAttributes ;
    	}
 }
 



Mime
View raw message