[Arp] ModelLocator - Events

Keith Takayesu ktakayesu at bank-banque-canada.ca
Wed Mar 15 12:43:10 PST 2006


I'm trying to make use of Christophe's ModelLocator ARPX, and I'm trying
it in baby steps, so I thought I'd share, and get some feedback from
this list. 

I first converted my calls from the Trunk version ModelLocator; it took
me a while to realize that I needed to use the getValue() to get the
contents of the Model, since getModel returns an object of type "Model".

i.e. thisModel =
ModelLocator.getInstance().getModel("listOfBooks").getValue();

My next step was to get the Views responding to Model changes, but this
is where I have a bit of a problem. I have set up a sort of pre-loader,
where I have a "preload" method on my Views that depended on some global
Models (UserInfo and translationStrings, for instance) to be populated
first.

My Application currently fires off the preload methods of all the Views
when this data has been loaded. I had followed the ARP example of just
having my Command (or, in my case, the Delegate) perform an AddModel
when the data came back.

When I changed all of this to Christophe's ModelLocator, I see that,
however, the AddModel() does not fire off the SetModel(), so the
"change" event is not fired. But then I got thinking, how does the View
know how to subscribe to a Model that has not been created yet?

So I have something like App -> onLoad -> getUserInfo -> getTranslations
-> invoke view preloaders

In my example View called Books, the preLoader does this:
 
ModelLocator.getInstance().addModel("listOfBookCategories", new
Object()); // Creates dummy model
ModelLocator.getInstance().getModel("listOfBookCategories").addEventList
ener("change", this);
dispatchEvent ( { type: "getListOfBookCategories" } );

Then, the getListOfBookCategoriesCommand peforms only a setModel()
instead of addModel(). 


Does this seem to be the correct way of using it? Does anyone have
experience with this ModelLocator?

All comments greatly appreciated; my next step will be to attempt to add
bindings to some custom V2 components we have built.

Blue Skies,
Keith



More information about the Arp mailing list