Announcement Announcement Module
Collapse
No announcement yet.
Spring Wiring MXML Components Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Wiring MXML Components

    We are using Spring ActionScript for a lot of our ActionScript objects and it works great. I was curious to know what the best strategy is for potentially wiring in MXML components. This seems like a bit overkill since Flex is already a declarative language ... but we are looking to implement a Tiles feature (like in Struts with tiles-def). Meaning we'd like to have one Flex app that can be tiled differently depending on the MXML file you wire through the application-context.xml file (some may want the navigation on the left and some on the right). I tried the following and it basically worked (below mainContainer is a Spring wired MXML component) but I started getting weird behavior with things like Validator (the validator never seems to execute):

    private function init():void
    {
    applicationContext = new FlexXMLApplicationContext("assets/configs/application-context.xml");
    applicationContext.addEventListener(Event.COMPLETE , onApplicationContextComplete);
    applicationContext.addEventListener(IOErrorEvent.I O_ERROR, applicationContextLoadFault);
    applicationContext.load();
    }

    private function onApplicationContextComplete(event:Event):void
    {
    var mainContainer:MainContainer = applicationContext.getObject("mainContainer");
    this.addChild(mainContainer);
    }

    Was instantiation of objects provided by SAS not meant for MXML components? if I just do new var mainContainer:MainContainer = new DefaultMainContainer(); it works fine. I also tried the following and it basically had the same effect as using SAS (it works but then I get weird behavior with validators and what not):

    var mainContainerClass:Class = getDefinitionByName("DefaultMainContainer") as Class;
    var mainContainer:MainContainer = new mainContainerClass();
    Last edited by jrayhawk; Jun 12th, 2009, 02:25 PM.

  • #2
    what you want is stage autowiring

    Hi there,

    the requested functionality has just been added to Spring Actionscript. Its called 'stage component wiring', you can find some of the early documentation here:

    SpringActionscript docs

    This functionality will be part of the 0.8 release of Spring Actionscript which will be released very soon (hopefully this coming week).

    Until then its best to just get the latest version from the SVN repository and make your own build. You can find the repository info here:
    Spring Actionscript repository info

    if you have any more questions, please feel free to do so,

    cheers,

    Roland
    Last edited by 666shooter; Jun 15th, 2009, 11:19 AM. Reason: edited link to spring as docs

    Comment


    • #3
      Thanks

      That's awesome - Thanks for the heads up. Looking forward to the 0.80 release!

      Comment

      Working...
      X