Results 1 to 9 of 9

Thread: Injecting the MXMLApplicationContext using the "this" reference.

Hybrid View

  1. #1

    Default Injecting the MXMLApplicationContext using the "this" reference.

    Hi!

    I read in the Spring Actionscript 1.1 documentation that's possible to pass a reference to the application context using the "this" reference in XML configuration files.
    I tried to do this in MXML configuration, but I didn't get success.
    Is there a possibility to pass a reference to the application context in the MXML configuration?

    Regards,
    Jacob.

  2. #2
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default yup

    Hey there,

    yea, that ought to work in both XML and MXML, can you post a snippet of your config? I might be able to see what's wrong there.

    cheers,

    Roland

  3. #3

    Default

    Hi, Roland!

    I created a sample to reproduce the error.
    I tried to set the ref attribute using the this keyword as a string and using the this keyword between braces.
    When I use the this keyword as string a compile error occurs (Initializer for 'ref': values of type org.springextensions.actionscript.context.support. mxml.MXMLObjectDefinition cannot be represented in text.).
    When I use the this keyword between braces a runtime error occurs (TypeError: Error #1034: Type Coercion failed: cannot convert MXMLContext@5feea61 to org.springextensions.actionscript.context.support. mxml.MXMLObjectDefinition.).
    I don't know if it's possible to attach the project zip file to this thread therefore the images that follow will show the project structure and the project source code.

    package-explorer.jpg
    injecting-mxml-context.jpg
    mxml-context.jpg
    view.jpg
    view-presentation-model.jpg

    Regards,
    Jacob.
    Last edited by Jacob Cabral; Jan 9th, 2012 at 01:03 PM.

  4. #4
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default

    Hm, putting 'this' as a string into the ref field ought to work, but apparently it doesn't. Definitely don't put it between braces because then you'll inject the configuration, which is not what you want.
    I'll look into this, for now, just let your presentation model implement IApplicationContextAware, then the current context will be automatically injected. At least you'll be able to continue that way. I'll try and see why the ref="this" config doesn't appear to work.

    cheers,

    Roland

  5. #5
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default

    Strange, I did a quick test with an MXML config like this:


    Code:
    <sas:Object id="test"
    		clazz="{Object}">
    	<sas:Property name="context"
    		  ref="this"/>
    </sas:Object>
    And this works perfectly, no compile error whatsoever. Are you sure you tried it exactly in the same way?

    cheers,

    Roland

  6. #6

    Default

    Hi Roland!

    I'm sorry. I haven't exposed the framework version I used in this sample.
    I'm using the version 1.1 and your suggestion didn't work (to use the this keyword as a string value).
    I tried your suggestion using the beta version and it works perfectly.
    I prefer to work with the version 2 of the framework. It's easiest to learn, better to configure and to implement robust applications, etc. But I'm worried because there isn't a final release of it.
    Is there a possibility to pass a reference to the application context in the MXML configuration, using the version 1.1 of the framework?
    I have a doubt about using MXML configuration in a multi-module scenario too, but i think this ought to be a new thread.

    Thanks for your attention!

    Regards,
    Jacob.
    Last edited by Jacob Cabral; Jan 10th, 2012 at 08:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •