[Arp] ModelLocator implementation (arpx)
Davies, Grant M.
grant.davies at nscorp.com
Fri Jan 6 06:52:29 PST 2006
Christophe, any chance of a 1 form example similar to what I did for the
arpx command controller/system event stuff ? Maybe we could refactor my
example to use your model locator ?
Grant
-----Original Message-----
From: Arp-bounces at ariaware.com [mailto:Arp-bounces at ariaware.com] On Behalf
Of Christophe Herreman
Sent: Friday, January 06, 2006 7:54 AM
To: General List for Ariaware RIA Platform users and developers
Subject: [Arp] ModelLocator implementation (arpx)
Hi guys,
here's what I have so far. I have been testing it in an existing project
and it works great so far. There are probably some things that might
need to be added or changed, so please give feedback where possible.
The classes you need are in the org.osflash.arpx.model.* package. Note
that arpx is not an official osflash project (yet? - I must talk to Aral
when he's over the car crash - hope you are ok !) but that was the most
appropiate package name as we have been discussing earlier. I have
several extensions, additions, fixes in this package but only released
the model subpackage in the attached zipfile.
To use it, I suggest you subclass ModelLocator and add public [const]
static's with the names of the models. Say you have a project called
"doza", make a DozaModelLocator and add public static var
MODEL_USERS:String = "modelUsers"; in there.
Then, in the views that dispatch system events, create a binding between
a component (most likely) and a model in the modelLocator.
There are 3 ways to do that:
- 1)
DozaModelLocator.getInstance().addBinding(DozaModelLocator.MODEL_FIRSTNAMES,
firstNames_cb, "dataProvider"); //binds the dataProvider property of the
firstNames_cb combobox to the model
- 2)
DozaModelLocator.getInstance().addBindingWithFormatFunction(DozaModelLocator
.MODEL_FIRSTNAMES,
firstNames_cb, formatFirstNames); //does the same but uses
DataGlue.bindFormatFunction() behind the scenes
- 3)
DozaModelLocator.getInstance().addBindingWithFormatStrings(DozaModelLocator.
MODEL_FIRSTNAMES,
firstNames_cb, "#firstName#", "#firstName#"); //does the same but uses
DataGlue.bindFormatStrings() behind the scenes
Then you need to set the model in the ModelLocator which will normally
happen in a command. So in the onResult() handler of your command, write:
DozaModelLocator.getInstance().setModel(DozaModelLocator.MODEL_FIRSTNAMES,
evt.result);
That's it. I haven't written anything for error handling yet.
Note that some of the implementation uses AS2LIB classes. Since I use it
in every project, I decided to use it in the extensions I write too. If
you haven't looked at AS2LIB then do so. You won't regret it.
regards,
Christophe
PS: I don't get paid by the AS2LIB guys !
More information about the Arp
mailing list