Announcement Announcement Module
Collapse
No announcement yet.
same old (new) thing... Try Injecting on SAS 2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • same old (new) thing... Try Injecting on SAS 2

    Hi all
    i dug in forums and internet but i didn't find any help about to make work [Inject] on .mxml and .as with SAS 2
    i did other app with SAS 1 and everything work fine

    In this one I'm using
    - SAS 2.0.1
    - as3commons-stageprocessing-1.1.0.swc
    - and all others..
    - Flash Builder 4.7 + SDK 4.6 + Air 3.8
    - XMLApplicationContext on onCreationComplete of Main

    i do
    - -keep-as3-metadata +=Inject
    - add classez on Main.mxml for bootstrap
    - add on app-context.xml
    PHP Code:
    <object id="autowiringStageProcessor" class="org.springextensions.actionscript.stage.DefaultAutowiringStageProcessor"/> 
    i try also
    - substitute [Inject] with [Autowired] and add in -keep-as3-metadata
    - load context in this odd mode
    PHP Code:
    var ac:ApplicationContext = new XMLApplicationContext"resources/app-context.xml" );
    var 
    rootView:Vector.<DisplayObject> = new Vector.<DisplayObject>();
    rootView.pushthis.stage );
    _context = new FlexXMLApplicationContextacthis.stage );
    _context.addNamespaceHandler( new EventBusNamespaceHandler() );
    _context.addEventListener(Event.COMPLETEonContextLoaded );
    _context.load(); 
    what's wrong?
    thanks in advance

  • #2
    i'm going on (crazy...)

    now i've configured like

    PHP Code:
    _context = new XMLApplicationContext"resources/app-context.xml" );
                    
    _context.addNamespaceHandler( new EventBusNamespaceHandler() );
                    
    _context.addEventListener(Event.COMPLETEonContextLoaded );
                    
    _context.configure( new FullXMLConfigurationPackage() );
                    
    _context.load(); 

    on top of app-context.xml

    PHP Code:
    <stage:autowiringstageprocessor object-selector="viewSelector"/>

        <
    object id="viewSelector" class="it.ekr.pe.mls.translator.presenter.AppViewSelector"/>

        <
    object id="eventHandlerProcessor" class="org.springextensions.actionscript.eventbus.process.EventHandlerMetadataProcessor"/> 

    but the AppViewSelector method is never called
    PHP Code:
    public function approve(object:Object):Boolean
            
    {
                return ( 
    object is IAppView );
            } 

    or never injected
    PHP Code:
            public var _appModel:AppModel;
            public function 
    get appModel():AppModel
            
    {
                return 
    _appModel;
            }
            [
    Inject]
            public function 
    set appModel(value:AppModel):void
            
    {
                
    _appModel value;
            }

               
            public function 
    MainPresenter( ) 

    Comment


    • #3
      solved!

      on Main.mxml
      PHP Code:
      private var _context:XMLApplicationContext;
                  protected function 
      onCreationComplete(event:FlexEvent):void
                  
      {
                      
      _context = new XMLApplicationContext"resources/app-context.xml" );
                      
      _context.addNamespaceHandler( new EventBusNamespaceHandler() );
                      
      _context.addEventListener(Event.COMPLETEonContextLoaded );
                      
      _context.configure( new FullXMLConfigurationPackage() );
                      
      _context.addRootViewthis );
                      
      _context.load();
                  }
                  
                  protected function 
      onContextLoaded(event:Event):void
                  
      {
                      
      addElement( new MainView() );
                  } 
      note:
      _context.addRootView( this );
      addElement( new MainView() );


      on app-context.xml
      PHP Code:
          <stage:autowiringstageprocessor object-selector="viewSelector"/>
          <
      object id="viewSelector" class="it.ekr.pe.mls.translator.presenter.AppViewSelector"/>
          <
      object id="eventHandlerProcessor" class="org.springextensions.actionscript.eventbus.process.EventHandlerMetadataProcessor"/> 

      the AppViewSelector is a way to filter what try to wiring (so you've to implements the empty interface IAppView for the all the interested views)
      PHP Code:
      public class AppViewSelector implements IObjectSelector
          
      {
              public function 
      approve(object:Object):Boolean
              
      {
                  return ( 
      object is IAppView );
              }
          } 
      hope this helps

      Comment

      Working...
      X