Announcement Announcement Module
Collapse
No announcement yet.
EventBus | EventListening Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            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

            Comment


            • #7
              sample app

              Hey Robson,

              you seem to be doing everything correctly, yet it doesn't work.
              Could you post a sample app that demonstrates the rpoblem? I'm sure once we see some source code we'll be able to determine quite quickly what's going wrong.

              cheers,

              Roland

              Comment


              • #8
                Hi Roland,

                I appreciate your offer. Thanks.

                I would have loved to post a sample app, which illustrates my problems. Unfortunately I can't reproduce my context very quickly. With the Google App Engine, Granite DS and Facebook API, there is a lot of stuff going on.
                I tried to simulate my problem in a smaller sample App, but as expected everything works like a charm over there. Comparing the console logs, more or less proofs the obvious: with these lines missing in the real Project.

                Code:
                DEBUG - (..) EventHandlerMetaDataPostProcessor - 
                Found [EventHandler] metadata on method public handler(Event):null
                
                DEBUG - (..) EventHandlerMetaDataPostProcessor - 
                Added event handler for sampleEvent on the EventBus
                It seems to me, that for this project, I have to get along with the "classic" event listening. Regarding the learnings I still have pass with SAS this is perfectly fine with me. For now

                Big thanks!
                Robson

                Comment

                Working...
                X