[Arp] ModelLocator - Events

nyls xxx at nyls.demon.nl
Thu Mar 16 00:27:57 PST 2006


Hello Keith, 

This is exactly how I have used it..  The only maybe 'small' difference is
that I try to keep all the model instantiating (addModel) at one place (
applicationForm ) because they are view 'independent' .. 

a small comment,

Gr nyls





---
-----Oorspronkelijk bericht-----
Van: Arp-bounces at ariaware.com [mailto:Arp-bounces at ariaware.com] Namens Keith
Takayesu
Verzonden: woensdag 15 maart 2006 21:43
Aan: General List for Ariaware RIA Platform users and developers
Onderwerp: [Arp] ModelLocator - Events

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

_______________________________________________
Arp mailing list
Arp at ariaware.com
http://ariaware.com/mailman/listinfo/arp_ariaware.com





More information about the Arp mailing list