[Arp] ModelLocator - Events
Keith Takayesu
ktakayesu at bank-banque-canada.ca
Thu Mar 16 06:05:51 PST 2006
Thanks, nyls.
However, I really have two "types" of Model, and I'm sort of being lazy
about it by having them all in the main ARP framework.
"Global" Models should be instantiated at the Application level, as they
can be used by any view. For instance, a list of books.
"Category" type of Model are specific to a particular View, and will not
be used anywhere else. They are simply used, for instance "list of book
categories", to populate a pull-down.
In a perfect world, I guess would create a sub-controller at the view
level, and the "Category" type Models would only exist there and be
self-contained. I might also expose a method for getting a particular
item for use in a summary screen, for instance. But for now, that will
have to wait until I understand how to load sub-screens from an external
source.
Blue skies,
Keith
-----Original Message-----
From: Arp-bounces at ariaware.com [mailto:Arp-bounces at ariaware.com] On
Behalf Of nyls
Sent: March 16, 2006 3:28 AM
To: 'General List for Ariaware RIA Platform users and developers'
Subject: Re: [Arp] ModelLocator - Events
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
_______________________________________________
Arp mailing list
Arp at ariaware.com http://ariaware.com/mailman/listinfo/arp_ariaware.com
More information about the Arp
mailing list