Home > Springas-subviewcontext

Springas-subviewcontext

Springas-subviewcontext is a project mainly written in ACTIONSCRIPT and GROOVY, it's free.

An extension for Spring Actionscript 1 which enables you to create a context for a subview of your application.

h2. Introduction

An extension for Spring Actionscript 1 which enables you to create a context for a subview of your application, just like it's already possible for modules.

h2. Important!

This extension is made for spring-actionscript 1.x. It won't be necessary to use this extension for spring-actionscript 2.0 since this functionality will be build in.

h2. How to use the extension

h3. Setup

  1. The first thing you need to do is to define an applicationContext for your subview, this applicationContext will contain the objects specific for your subview (like presentationmodels, mediators, models,...).

  2. Then you have to instantiate your context in your subview, like this:

_tabApplicationContext = new RootComponentXMLApplicationContext(this); // this == the subview _tabApplicationContext.parent = parentApplicationContext; _tabApplicationContext.addConfigLocation("applicationSubViewContext.xml"); _tabApplicationContext.load();

  1. from now on the dependencies of your subview and its subcomponents will be automatically injected when they get instantiated.

h3. Popups

Popups are somewhat special when it comes to injection. Because popups aren't added to the default displayList it's impossible for the extension to know when the popup is added to the view. Therefore you have to manually register the popup with the applicationContext. Follow these steps to do this:

  1. define the AutowireViewRegistrator class as a singleton in your subview applicationContext.

  2. define a property of type IViewRegistrator in the class where the popup is created, like this:

    [Autowired]
    public var viewRegistrator:IViewRegistrator;
    
  3. then register the popup with the viewRegistrator:

    viewRegistrator.registerView(popup);
  4. from now on your popup (and any new subcomponents) will get autowired.

Previous:testing