Hi Christian,

   The advantages are many to have an object registry.

#1. With an object registry, you can have named access to objects, to iterate through the objects and perform
         actions upon them (as simon has rightly said).

#2. If you are creating realtime applications (i.e, product like) you would end up
         building custom objects (like forms, Grids, Lookups).
         (Ex.
think about a generic data entry form, with a api on top of it to quickly create the visual screen along
           with features for
- Creating variables & binding them to a visual control [Ex. QxTextField] - Loading data from a xml request and updating the variables and with the help of the object registry,
             update the visual controls
- Iterate and collect data from the visual controls using the object registry and fire a xml request to push/save
             the data.
           )
An object registry would come in very handy, to code such iterative tasks and thus saving on production time.

#3. With an object registry, and having one at the level of every container control (on the likes of the "children" property) will open up scope to do a lot many things, on the lines of building / extending the visual framework.

cheers
-sundar

Simon Bull wrote:

Hi Christian,

With an ObjectRegistry you can use code to iteratively create and register instances. E.g.; you couldn't do this and maintain global references to each instance:

for (name in propertySheet) {
    var  instance =  createProperty(name);
}

Simon

*/Christian Boulanger <[EMAIL PROTECTED]>/* wrote:

    Hello Dann,

    what would be the advantage of the object registry over just using
    global variables? If you omit the "var" before the variable
    declaration,
    you can access your widget from anywhere...

    function foo()
    {
    globalWidget = new QxWindow;
    }

    function bar()
    {
    globalWidget.open();
    }

    C.

    Danny Adair schrieb:
    > Hello,
    >
    > If you want to access objects by a user-defined name from anywhere,
    > use the code below (ObjectRegistry.js).
    >
    > Yesterday, I wanted to access a qooxdoo object from a function which
    > hadn't created it.
    > Unfortunately, qooxdoo doesn't seem to support that at this
    stage (and
    > iterating through children and checking, e.g., their label/value is
    > certainly not a real option).
    >
    > Google led me to QxObjectDatabase, and that's what this code is
    based
    > on: User-defined strings are mapped to qooxdoo "unique id"s (the
    > hashcodes in QxDatabase). I'm not into Javascript (excuse my Python
    > indentation style) so I'm sure this can be improved. I didn't do any
    > error handling.
    >
    > Hope this will help others.
    >
    > Cheers,
    > Danny
    > [EMAIL PROTECTED]
    >
    > /*
    > Object Registry
    >
    > Usage:
    > 1. Create a global registry object, e.g.
    > var object_registry = new ObjectRegistry();
    > 2. To register an object under a name, use
    > object_registry.set(some_object, 'some object')
    > 3. To access an object under its registered name (from
    anywhere), use
    > obj = object_registry.get('some object')
    >
    > Advanced Usage:
    > You can register ObjectRegistry objects to create "sub registries":
    > 1. Create a new ObjectRegistry object (does not need to be
    global), e.g.
    > var sub_registry = new ObjectRegistry();
    > 2. Register the new sub registry with the global registry, e.g.
    > object_registry.set(sub_registry, 'my sub registry')
    > 3. To register objects with the sub registry, use
    > sub_registry.set(other_object, 'other object')
    > 4. If you don't have the sub registry in your scope and want to
    register
    > an object with it, access it through the global registry first:
    > object_registry.get('my sub registry').set(other_object, 'other
    > object')
    > 5. Correspondigly, to access an object registered in the sub
    registry,
    > use
    > obj = object_registry.get('sub_registry').get('other object')
    > */
    >
    > function ObjectRegistry()
    > {
    > this._mapping = {};
    > };
    >
    > ObjectRegistry.prototype.set = function(obj, id)
    > {
    > if (obj instanceof ObjectRegistry)
    > {
    > this._mapping[id] = obj;
    > }
    > else
    > {
    > this._mapping[id] = obj.toHashCode();
    > };
    > };
    >
    > ObjectRegistry.prototype.get = function(id)
    > {
    > var entry = this._mapping[id];
    > if (entry instanceof ObjectRegistry)
    > {
    > return entry;
    > }
    > else
    > {
    > return QxObjectDataBase[entry];
    > };
    > };
    >
    >
    > -------------------------------------------------------
    > Using Tomcat but need to do more? Need to support web services,
    security?
    > Get stuff done quickly with pre-integrated technology to make
    your job
    > easier
    > Download IBM WebSphere Application Server v.1.0.1 based on Apache
    > Geronimo
    >
    
http://sel.as-us.falkag.net/sel?cmd_______________________________________________

    >
    > Qooxdoo-devel mailing list
    > [email protected]
    > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



    -------------------------------------------------------
    Using Tomcat but need to do more? Need to support web services,
    security?
    Get stuff done quickly with pre-integrated technology to make your
    job easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache
    Geronimo
    http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    _______________________________________________
    Qooxdoo-devel mailing list
    [email protected]
    https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------
The LOST Ninja blog: Exclusive clues, clips and gossip. <http://us.rd.yahoo.com/mail/tag/au/**http%3A%2F%2Fau.blogs.yahoo.com%2Flostninja>





-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to