On Sat, Mar 6, 2010 at 09:11, Steve Jobs <[email protected]> wrote:
> Yesterday I posted my first mail in this mailing list but looks I did some
> mistake.
>
Nope, no mistake except that you posted it at around 6am Saturday morning in
Germany where the core team is based, midnight Friday night east coast USA,
so there weren't very many people available to answer your question then.
Since this is a global group of folks, you just need to consider the day and
time.
> I am new to qooxdoo
>
Anyway... Welcome to qooxdoo!
> I am creating a qooxdoo class (MyClass) and want that its one instance
> (myObjN) should add a listener to some other already created instances
> (myObjA, myObjC,...) of the same class.
> Or is there any way to get map/array of handles of all existing objects on
> some class
>
There is no inherent mapping of an a variable name to a string representing
that variable. You have a few ways to go about this, though.
Each qooxdoo object has a "hash code" which you can retrieve with
obj.toHashCode(). When the object was instantiated, that hash code was saved
in the qooxdoo Object Registry. You can retrieve the object that has a known
hash code using the static method qx.core.ObjectRegistry.fromHashCode(hash)
so if instead of saving a string of your own choosing, you save the hash
code, you should be all set.
You can also create your own mapping in your Application object (in your
source/class/YourApplicationName/Application.js file). In the members
section, add:
/** Map object names to their instantiated object */
__objectMap : null,
In the main() method, add:
this.__objectMap = { }; // initialize to an empty map
Then, also in the members section, add two new methods:
/**
* Create a mapping of an instantiated object to a specified name
*
* @param obj {Object}
* A reference to some object
*
* @param objName {String}
* The name to be assigned to later access this object
*/
addObjectToMap(obj, objName)
{
this.__objectMap[objName] = obj; // Associate the object with the name
},
/**
* Retrieve the object, previously saved with addObjectToMap(), of the
specified name
*
* @param objName {String}
* The name previously associated with the desired object
*
* @return {Object}
* The object associated with the specified name;
* undefined if no object is associated with that name.
*/
getObjectFromMap(objName)
{
return this.__objectMap[objName]; // Give 'em the object with the
specified name
}
Each time you instantiate an object, associate it with a name like this:
var myApp = qx.core.Init.getApplication(); // Retrieve a reference to the
Application object
myApp.addObjectToMap(obj, name); // Associate the object 'obj' with the name
'name'
To retrieve an object, do the reverse:
var myApp = qx.core.Init.getApplication(); // Retrieve a reference to the
Application object
var obj = myApp.getObjectFromMap(name); // Retrieve the object associated
with the name 'name'
One of those options (using hash codes, or creating your own mapping in your
application object) should do what you need.
Cheers,
Derrell
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel