Fwd: [dojo-contributors] Widget property parsing

Neil neildev at gmail.com
Thu Jun 29 20:31:53 EDT 2006

From: Neil neildev at gmail.com Neil J
Date: Jun 28, 2006 5:45 PM
Subject: Re: [dojo-contributors] Widget property parsing
To: alex at dojotoolkit.org


Thanks for your detailed response to my inquiry.  I do have a few concerns
though, see below

 On 6/27/06, Alex Russell <alex at dojotoolkit.org> wrote:
> Hi Neil,
> One quick note: it would be good if your email messages contained your
> full name somewhere, as we now have two Neil's who are heavily involved
> in the project.
> On Monday 26 June 2006 5:56 pm, Neil wrote:
> > In the process of patching the dojo toolkit for some bugs I have come
> > across a problem with the widget package.  There currently does not
> > exist a way to map attributes from a given tag that do not follow the
> > convention, name-value pair.

 *Originally, when the object is parsed, the attributes are mapped in
key,value pairs from the frag object into the args object, ie. name,
maxlength etc.  In the mixInProperties method, if I recall correctly, the
args are then parsed and mapped into the widget object in question.  Since
some of the attributes from tags do not contain name-value pairs, there are
some properties that are not populated into the args object.  Once in the
mixInProperties (or some method similar), these properties are not taken
into account within the widget. *

Assuming that I understand you correctly (which I'm not certain of), I
> don't think you're correct in this assertion. Arrays and map-style
> objects are handled by the mixInProperties() method. Arrays are
> replaced with new array objects which contain strings split on the ";"
> chrachter from the node attribute. If your widget contained:
>        this.foo = ["bar", "baz"];
> You could repalce it in the markup with:
>        <div dojoType="blah" foo="thud;xyzzy">...</div>
> Objects are likewise mapped back from attribute values:
>        this.foo = {bar: "blah blah", baz: "blabber"};
> could be created with:
>        <div dojoType="blah" foo="bar:blah blah;baz:blabber">...</div>
> > Some attributes within desired
> > supported tags only contain a name value where it is assumed that the
> > value implies an affirmative action.
> Properties set on nodes that do not match an initially populated
> property of a widget object are available as raw string values in the
> extraArgs map which is a property of every widget object.
> You can retreive a custom property in a widget's fillInTemplate method
> like this:
>        fillInTemplate: function(args, frag, parent){
>                // you can cast it to something other than a string here
>                this.someCustomProperty = this.extraArgs["somecustomproperty"];
>                // ...
>        }

 *I have followed a similar methodology as you suggested in building out the
widget from a template.  Within the fillInTemplate method, since the desired
attribute was not mapped into the args/Widget object, I used the frag object
to set the disired conditions within the dojo created dom object.  Does this
seem reasonable.  It works but with scoping the desired behavior externally
from the frag object and not from within a Widget property seems like a hack
to me. *

With all of that said, I'm still not sure that I understand your
> original concern adequately to know if this is a reasonable solution to
> the problem you're trying to describe.
> Regards
> > This mapping of attributes to
> > properites within an object occurs when parsing the tree and building
> > the widget.  Currently I have worked around the lacking of mapping of
> > some tag attributes to objects by using directly the "frag" object to
> > determine the correct behavior of the widget. I believe there should
> > be a more elegant and generic means by which the attributes missed by
> > the mapping should be conducted in the future.  Any suggestions?
> --
> Alex Russell
> alex at dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20060629/8e16439c/attachment.htm 

More information about the dojo-contributors mailing list