How does the SAS 2.0 event handling config work? How to enable metadata config?
Hi all,
I'm trying to switch my project from SAS 1.0 to 2.0, but I'm having a little bit of troubles with the (Static)EventBus handling.
The problem is that in my Mxml config, the event handler config doesn't seem to work (maybe I'm missing a key part in the configuration) as I thought it would:
PHP Code:
<eventbus:EventHandler instance="serviceLayer">
<eventbus:EventHandlerMethod name="findAllHandler" eventName="{AppEvent.FIND_ALL}"/>
</eventbus:EventHandler>
<!--Service-->
<sas:Object id="serviceLayer" clazz="{ServiceLayer}">
<sas:ConstructorArg ref="dBService"/>
</sas:Object>
<sas:Object id="dBService" clazz="{DBService}">
<sas:ConstructorArg ref="serverRemoteObject"/>
</sas:Object>
With this configuration my "findAllHandler" doesn't get triggered.
Though when I add the listener manually in my configuration it does seem to work:
PHP Code:
StaticEventBus.addEventListener(AppEvent.FIND_ALL, findAllHandler);
Also I can't seem to get the metadata config working (I do have my MXML config working in the project, maybe I also need to add something in there to activate metadata config options?):
PHP Code:
[EventHandler]
public function findAllHandler(event:AppEvent):void {
log.debug("Received findAll event from EventBus: {0}", [event]);
...
This used to work in my previous SAS 1.0 config, but doens't get picked up atm...
Thanks a whole lot in advance!
Best wishes,
Jochen
PS: I also tried this kind of config, without succes:
PHP Code:
<!--Service-->
<sas:Object id="serviceLayer" clazz="{ServiceLayer}">
<sas:EventHandlerMethod name="findAllHandler" eventName="{AppEvent.FIND_ALL}"/>
<sas:ConstructorArg ref="dBService"/>
</sas:Object>
PPS: Using the EventRouterConfiguration on the dispatching side makes the previous EventHandlerMethod in the config block work:
PHP Code:
<sas:Object id="ebHelper" clazz="{EbHelper}">
<sas:EventRouterConfiguration eventNames="{AppEvent.FIND_ALL}"/>
</sas:Object>
But only the events dispatched by the instance (as opposed to my static dispatching methods defined who dispatch on the static eventbus) get caught:
PHP Code:
//
public function findAll(className:String, processString:String=null, complete:Function=null, error:Function=null, retry:Function=null, ...retryparams):void{
...
dispatchEvent(new AppEvent(AppEvent.FIND_ALL, [className, processString, completeWrapped, errorWrapped]));
}
public static function findBy(classNameToFind:String, instanceClassNamesToMatch:*, processString:String=null,
complete:Function=null, error:Function=null,
retry:Function=null, ...retryparams):void{
StaticEventBus.dispatchEvent(event);
}
Is this normal behavoir? Is the use of the static eventbus discouraged as opposed to routing "normal" events?