From xap-commits-return-105-apmail-incubator-xap-commits-archive=incubator.apache.org@incubator.apache.org Thu Jul 06 20:00:17 2006 Return-Path: Delivered-To: apmail-incubator-xap-commits-archive@locus.apache.org Received: (qmail 25292 invoked from network); 6 Jul 2006 20:00:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Jul 2006 20:00:17 -0000 Received: (qmail 83905 invoked by uid 500); 6 Jul 2006 20:00:17 -0000 Delivered-To: apmail-incubator-xap-commits-archive@incubator.apache.org Received: (qmail 83875 invoked by uid 500); 6 Jul 2006 20:00:17 -0000 Mailing-List: contact xap-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: xap-dev@incubator.apache.org Delivered-To: mailing list xap-commits@incubator.apache.org Received: (qmail 83866 invoked by uid 99); 6 Jul 2006 20:00:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 13:00:17 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 13:00:16 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 3EC011A981A; Thu, 6 Jul 2006 12:59:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r419686 - /incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Date: Thu, 06 Jul 2006 19:59:55 -0000 To: xap-commits@incubator.apache.org From: mturyn@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060706195956.3EC011A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 ; } }