dmachi / dojox_application

Dojox Application Framework for mobile, tablets, and desktops
Other
27 stars 24 forks source link

Should be able to set the viewId in the config, and provide helper functions to get to a view. #47

Open edchat opened 12 years ago

edchat commented 12 years ago

From Issue #42, msmiths wrote: Hi Ed,

So I see the generated id when I am debugging my application... and I have also had to write a helper function to allow me to find a given view within my application, starting at the application level since I know the name of this global.

In the Chrome Developer Tools debugger, I can see that id of the view is constructed using the id of the application and the ids of the all of the views in the chain. This is also used as the key in the associative array used to store the views in the "children" attribute of the objects. So, my helper function looks like this:

_getView : function(app, childViewName) {
    var view = null;
    if (app && app.children) {
        for (var name in app.children) {
            if (name == childViewName) {
                view = app.children[name];
                break;
            } else {
                view = this._getView(app.children[name], childViewName);
            }
        } // FOR
    }
    return view;
},

I can also see that the "name" attribute for the view objects is just as it appears in the configuration... so I could have implemented the helper function to take an array of view names and used those to walk the hierarchy of view objects, but I thought that using the id was simpler.

Either way... my assertion remains that I should not have to understand the structure of my application in order to construct the id for a given view, I should be able to specify the id that I want to assign to each view as part of the configuration for that view. Also, I should not have to implement my own helper functions to navigate objects in the framework... the relevant application and view classes should provide the relevant functions that allow me to find views (or other framework objects such as models or stores) within the hierarchy.

Thanks. Martin.

edchat commented 12 years ago

Regarding the getVeiw helper function, I can add a helper function to app to get to a view by name(s), but it seems to me that it may be better to take what would amount to the target, with something like "view1,view2" using the view names. The app can be gotten from the view with this.app, so you will be able to call this.app.getView("view1,view2") from a view. Does that work for everyone?