Announcement Announcement Module
Collapse
No announcement yet.
Autowired view components compiler settings Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Autowired view components compiler settings

    Hi All,

    I was trying to get the [Autowired] going for dynamically assigning models to views.

    Apparently my compiler settings were wrong. On many places on the web you see examples like:
    -keep-as3-metadata +=Autowired,Mediate

    Maybe this works for ant builds but in my FlexBuilder compiler settings this didn't work. It took me long to find out what was wrong. For me only the next syntax works:
    -keep-as3-metadata "Bla" -keep-as3-metadata "Test" -keep-as3-metadata "Autowired"

    So quote them and for each metadata add a separate -keep -meta-data

    BTW im on OSX, FlexBuilder standalone 3.0.205647

    This would be a nice one to include in the docs if this is a general thing instead of my funky system. Otherwise this post may be useful for anyone having the same issues.

    Arnoud

  • #2
    Another trap

    Also make sure you instantiate / load the applicationcontext when the application is finished.

    my handler looks like this:

    private function loadApplicationContext( event : Event ) : void
    {
    applicationContext = new FlexXMLApplicationContext(Application.application. parameters.applicationContexts.split(","));
    applicationContext.addEventListener(Event.COMPLETE , initApplication);
    applicationContext.load();
    }

    if i call it on:
    initialize, preinitialize or creationComplete
    of the main application the views don't get autowired.

    If i call it instead on applicationComplete it works.

    Probably this has something to do with the internals of hao and when the systemmanager is available which listens to the Event.ADDED for assigning stuff to [Autowired] properties.

    Hope this is helpful for some people.

    Arnoud

    Comment


    • #3
      thanx for the tip

      Thanx for the tip Arnoud,

      I've added a note in the documentation about this exception, I guess this is a flexbuilder OSX issue, I hadn't heard aboutthis before.

      As for the autowiring not working after creationcomplete, etc. Are you using the latest version from the SVN trunk?
      Just recently we added pre-initialisation caching, so as soon as the systemManager becomes available every object that's been added to the stage before the application context has finished parsing its configuration will be cached and autowired when the app context is ready.

      cheers,

      Roland

      Comment


      • #4
        Works!

        Hi Roland,

        thank you for the quick reply. You are right, it works like a charm now.
        I'll be a bit more careful with my tips as the second one is not valid anymore and was actually about an unfinished class.

        Just a quick question: Do you guys mind if people asking / remarking about the version in svn? I can imagine that you want to spend your time on coding instead of anwering qustions about stuff that is not finished yet. If so i'll be quiet until the 0.8 release ;-)

        Arnoud

        Comment


        • #5
          every kind of tip is welcome

          Hey Arnoud,

          I think the whole idea behind open source is that it is 'open', which means that everyone can follow the development step-by-step in the trunk. And if you see anything happening there that you have questions or comments about then please always feel free to chime in here at the forums or on the developer's mailing list, it might save someone heading down a wrong path or give hem him/her a great idea for improvement.
          Also if there's parts in the documentation that you find incomplete, confusing, etc, all comments and suggestions are more than welcome.

          cheers,

          Roland

          Comment

          Working...
          X