Read this: http://qooxdoo.org/documentation/0.8/classes#instance_members
T.
Loïc Bresson -- Novlog wrote:
> Hi.
>
> I have a class that basically looks like this:
>
> qx.Class.define("EditorWindow", {
> ...
> members: {
> dataPanes: [],
> ...
> }
> });
>
> The member dataPanes is an array that I use to store widgets that I
> don't want to instantiate several times. If the widget I need doesn't
> exist in the array, I create it and put it in. If it does exist, I use
> the existing one.
>
> My problem comes from the fact I can have two EditorWindow at the same
> time in my application, and those two windows must have their own arrays
> of widgets (one window can only have one widget of type A, but there can
> be several widgets of type A if there are in different windows).
>
> The problem is that the dataPanes member seems to be shared between my
> two EditorWindow objects.
>
> 1/ I create a first EditorWindow (let's call it editor1), and ask for a
> widget of type A. This type of widget has not been created yet for this
> window, so one is created and put it in editor1.dataPanes
>
> 2/ I open a new EditorWindow (let's call it editor2), and ask for the
> same type of widget. Surprisingly, the widget is found in
> editor2.dataPanes, and used. In fact, it is the same as in editor1, and
> if I want to do something with this widget of type A in editor2, it will
> affect the one in editor1, something that I obviously don't want.
>
>
>
> After several tries to fix this, I did the following:
>
> qx.Class.define("EditorWindow", {
> construct : function() {
> ...
> this.dataPanes = [];
> },
>
> members : {
> ...
> }
> });
>
> I do not define dataPanes in the members, but create it in the
> constructor. And everything works well!
> Why does that works with this way, and not with the other one?
>
> Thanks.
>
>
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel