On Tue, Nov 25, 2008 at 9:43 PM, Derrell Lipman
<[EMAIL PROTECTED]> wrote:
> On Tue, Nov 25, 2008 at 4:50 PM, Patrick Paskvan <[EMAIL PROTECTED]>
> wrote:
>>
>> We could tie population of the select box on it's "click" event.  The
>> handler would change just a bit (assigning vars sb and arr for
>> clarity):
>>
>>               this._sb.addListener("click", this._fillBox, this);
>>
>>                _fillBox : function (e)
>>                {
>>                        var sb = e.getTarget();
>>                        var arr = this.getData();
>>                        for (var i=0; i<arr.length; i++)
>>                        {
>>                                sb.add(new qx.ui.form.ListItem(arr[i]));
>>                        }
>>                }
>>
>> We can go that route.  It's just not related to when the "data"
>> property of "sample.thing" is set.  I was hoping (assuming) that the
>> select boxes could subscribe to the "changeData" event and get
>> notified and the handler would get all of the appropriate data in the
>> event object.  Now I feel silly, but I thank you for pointing out my
>> bad assumption.
>
> If I'm following you correctly, you're looking for changes to the "data"
> property to be propagated to your (possibly multiple) SelectBoxes.
> Specifically, you'd do something like this:
>
> properties :
> {
>   data :
>   {
>     check : "Array",
>     init : null,  // initialize this to an array in the constructor!
>     apply : "_applyData"
>   }
> },
>
> members :
> {
>   _applyData : function(value, oldValue)
>   {
>     var selectBoxes = [ this._sb1, this._sb2 ];
>     for (var i = 0; i < selectBoxes.length; i++)
>     {
>       selectBoxes[i].removeAll();  // or whatever method clears the list.  I
> don't recall how it's done.
>       for (j = 0; j < values.length; j++)
>       {
>         selectBoxes[i].add(new qx.ui.form.ListItem(values[j]);
>       }
>     }
>   }
> }

Great, that's exactly what we were doing before I got on the wrong track.

> Note the comment about initializing the property in the constructor.  If you
> have a property with an initial value that is a reference type (object,
> array) you'll end up SHARING that same array among all instances of the
> class.  Very likely not what you want.  So instead, you give it an initial
> value of null, and do this.setData([]) in your constructor so the instance
> gets its very own array for the property value.
>

Good tip.  Haven't been bitten by that yet, but I'm sure you just
saved me a future afternoon.

Thanks again,
Pat

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to