Results 1 to 8 of 8

Thread: EventBus | EventListening

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    8

    Default EventBus | EventListening

    Hi Folks,

    I am quite new to SAS, so please excuse if the following is a bit of a "no-brainer".

    What might be the reason, why the first code-Snippet triggers my function, but the second doesn't.

    Code:
    1) 
    [...]
    EventBus.addEventListener("allDataLoaded",onDataComplete);
    
    2)
    [EventHandler(name="allDataLoaded")]
    protected function onDataComplete(event:Event):void {...}
    Many Thanks,
    Robson

  2. #2
    Join Date
    Oct 2008
    Location
    Belgium
    Posts
    160

    Default

    Hi Robson,

    please see the last part of section 5.1.3 in the EventBus documentation: http://www.springactionscript.org/do...ta_annotations

    In short, you need to
    - add the EventHandlerMetaDataPostProcessor to the context
    - update the compiler argument to preserve the metadata when compiling

    As of release 1.1, you can also activate the post processor by using the context:metadata-config element in the context.

    regards,
    Christophe
    Christophe Herreman
    Spring ActionScript Founder
    http://www.herrodius.com

  3. #3
    Join Date
    Oct 2010
    Posts
    8

    Default

    Hi Christophe,

    thanks for your reply. Unfortunately I checked both, but the metadata approach still doesn't do the trick.

    To exclude misunderstandings, I have this part in the application-context.xml, which is succesfully loaded at app-startup
    Code:
    <object id="eventhandlerProcessor" 
    class="org.springextensions.actionscript.ioc.factory.config.EventHandlerMetaDataPostProcessor"/>
    My complete compiler-arguments look like this
    Code:
    -services "C:\workspaces\[...]\war\WEB-INF\flex\services-config.xml" 
    -locale=de_DE,en_US,es_ES -source-path=locale/{locale} 
    -allow-source-path-overlap=true 
    -keep-as3-metadata+=EventHandler
    Additionally I have declared the following inside the main mxml.
    Code:
    private var _compiledClasses:Array = [
    DefaultAutowiringStageProcessor, 
    EventHandlerMetaDataPostProcessor, 
    ApplicationController
    (...)
    ];
    Any Ideas, what I am doing wrong?

    Many Thanks,
    Robson

  4. #4
    Join Date
    Oct 2008
    Location
    Belgium
    Posts
    160

    Default

    Everything seems to be OK. Is this in a class that is managed by the container or a view component? The instance needs to pass through the container logic for the processors to be applied.
    Christophe Herreman
    Spring ActionScript Founder
    http://www.herrodius.com

  5. #5
    Join Date
    Oct 2010
    Posts
    8

    Default

    Hi Christophe,

    thanks again. I guess I need to do some more study of SAS.

    So, yes, the snippet is inside a view component, which to make things worse, doesn't have a corresponding presentation model.

    With that being said, am I assuming correct, that I first need to refactor the logic into a separate class and add this to the app-context to get the metadata notation to work?

    Many Thanks,
    Robson

  6. #6
    Join Date
    Oct 2010
    Posts
    8

    Default

    Update:

    I did what I thought to be the solution.

    - Extracetd the logic, including the methods for eventBus-Listening into a presentation Model
    - added the presentation-Model to the app context
    - added the presentation-Model to the List of compiled classes

    Nevertheless it isn't working - aka I am still doing something wrong.

    Any advice left in the tank? Does the class dispatching the events via the eventBus have to be registered as well?

    Thanks,
    Robson

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •