Hi Romain,

you can work around that issue by initializing the member in the constructor,
like you did. Another way is the described here:
http://qooxdoo.org/documentation/0.7/defining_properties#defining_an_init_value
This keeps the nice property alive ;)

I've come along this kind of problem myself some time ago and remember very
well that it took me a while to realize that something like this
<code>
  properties: {
    foo : {
      init: {}
    },
    bar : {
      init: []
    }
  }
</code>

...produces "class-static" properties. I currently prefer the following style
to create one instance of "reference-types" (Array, Object, Date) for each
object:

<code>
  constructor : {
    this.initFoo({}); // each instance gets it own map
    this.initBar([]); // each instance gets it own array
  },
  properties: {
    foo : {
      check: "Map"
    },
    bar : {
      check: "Array"
    }
  }
</code>

But be aware: The "init" methods will only work with parameters when there is
no init key in the property declaration!
If you have an init key in the property declaration, you can use the general
"set" method.
Confused? Me too ;) Maybe an example helps

<code>
  constructor : {
    this.initZero();   // works! no params
    this.initZero(3);  // init dosn't work with params
    this.initZero([]); // init dosn't work with params
    this.setZero(3);   // works! set is always O.K.
    this.setZero([]);  // works! set is always O.K.

    // "init:null" is no difference:
    this.initOne();    // works! no params
    this.initOne(1);   // init dosn't work with params
    this.initOne([]);  // init dosn't work with params
    this.setOne(3);    // works! set always is O.K.
    this.setOne([]);   // works! set always is O.K.

    this.initThree([]); // works! "...No init no cry ;)..."
  },
  properties: {
    zero : {
      init : 0
    },
    one : {
      init : null
    },
    three : {
    },
  }
</code>


So, back to "our" issue: Something like this should work, too:

<code>
  construct: function(tableModel, custom) {
    this.initLabelList(new Array());
  },
  properties :
  {
    /**
     * list of labels to display
     * labelList[col][row] is displayed when the mouse is over the cell
     * located in the column col and in the row row
     */
    labelList : {
      check : "Array"
    }
  }
</code>

Please note, that I did not check any of the code above...But the general
concept should be visible.


/Kuddel



>> [...]
> Actually I found a problem,
> I'm using several instances of the ToolTipTable and is seems that all 
> the instance are sharing the same property labelList
> 
> I fixed that by not using qooxdoo property :
> 
> Replace :
> 
>   properties :
>   {
>    /**
>     * list of labels to display
>     * labelList[col][row] is displayed when the mouse is over the cell 
> located in the column col and in the row row
>     */
>     labelList :
>     {
>       init : new Array(),
>       check : "Array"
>     }
>   }
> 
> by :
> 
>  construct: function(tableModel, custom)
>   {  
>     this.__labelList = new Array();
>      [ ... ]
>   }
> 
>   members :
>   {
>    
>     getLabelList : function()
>     {
>         return this.__labelList;
>     },
>    
>     setLabelList : function(list)
>     {
>         this.__labelList = list;
>     },   
>     [ ... ]
>   }
> 
> There is no problem with the property defaultLabel so I'm a little 
> confused ... it seems that the 'new Array()' init is done only one for 
> all the instances ... if you have an idea !
> [...]


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to