2011-01-11

Parsley Framework tips

As I have been using Parsley lately, thought I'd share a couple of tips. Here goes...

Selectors on result methods
When declaring the result method of your command class, it probably looks like this:

[CommandResult]
public function onResult( ... ):AsyncToken { ... }

That's nice, but if you have several commands classes in your project, Parsley will end up calling all of them once a remote method completes. You need to specify a selector which has the same event code as the associated event class in each command. So the above becomes:

[CommandResult(selector="getContacts")]
public function onResult( ... ):AsyncToken { ... }

Global error handler
Following the same theme, for fault methods, you probably want to have a global one, so that you can display a uniform message when things go wrong. You can accomplish this by creating a class that has a single method with the following declaration:

[GlobalRemoteObjectFaultHandler]
public function handleFault( event:FaultEvent ):void { ... }

And then just declare it in your Parsley configuration file, like so:

<someNS:GlobalAlertHandler />

And finally, since this is not a Parsley feature directly, but a Cairngorm 3 add-on, you will need to download and include in your project the Cairngorm Integration Library, which you can get from here.

CloseEvent and PopUps
If you are using the Cairngorm PopUp Library, then careful when your popup MXML component is throwing the CloseEvent. Throwing this event will cause the popup to close, but if your MXML component is overriding the close handler, you won't get the result you expect!

2 comments:

Anonymous said...

Its like you learn my mind! Үou appеar to knoω a lot approximatеlу thіs, like you wгote thе booκ in іt or sοmething.
Ι fеel that уou јust can do with somе p.
с. to power the meѕѕage home a bіt, but іnstead οf that, thіs is fаntastіc blog.
An excellent rеad. I'll certainly be back.

Also visit my webpage ... utility trucks

Anonymous said...

Fаntastiс gooԁs from yοu, mаn.
I've consider your stuff prior to and you'rе simply too fantastic.
I really like ωhat you haѵе acquiгеd here,
сегtaіnly lіke whаt you're saying and the way in which you are saying it. You are making it enjoyable and you continue to care for to keep it sensible. I can't
wаit to lеarn far more frοm you.

That is actually a tremеndous ѕitе.


Alsо vіsit my site :: search engine optimization dallas