Results 1 to 4 of 4

Thread: Inject static property

  1. #1
    Join Date
    Dec 2009
    Posts
    13

    Default Inject static property

    Hi, all.

    I can't seem to find any documentation on how to inject the value of a static property of class A into a property of class B. Specifically, I want to inject the value of HTTPService.RESULT_FORMAT_E4X into an instance of another class using Spring AS. Any ideas?
    I tried using factory-method already. That didn't work.
    Here's what I tried -

    Code:
    <object id="b" class="B">
    	<constructor-arg>
    		<object class="mx.rpc.http.HTTPService" factory-method="RESULT_FORMAT_E4X" />
    	</constructor-arg>
    </object>

    Thanks much.

    Jules

  2. #2
    Join Date
    Dec 2009
    Posts
    4

    Default

    Hi there,

    Take a look at the FieldRetrievingFactoryObject (http://www.springactionscript.org/do...ther_obj ects).

    This should do the trick:

    Code:
    <object id="b" class="B">
      <constructor-arg>
        <object class="mx.rpc.http.HTTPService">
          <property name="resultFormat">
            <object class="org.springextensions.actionscript.ioc.factory.config.FieldRetrievingFactoryObject">
              <property name="staticField" value="mx.rpc.http.HTTPService.RESULT_FORMAT_E4X"/>
            </object>
          </property>
        </object>
      </constructor-arg>
    </object>

    Cheers

    herb

  3. #3
    Join Date
    Dec 2009
    Posts
    13

    Default

    Awesome! Thanks!
    J

  4. #4
    Join Date
    Oct 2008
    Location
    Belgium
    Posts
    160

    Default

    Hi,

    you can also use the "util" namespace for this:

    Code:
    <util:constant static-field="mx.rpc.http.HTTPService.RESULT_FORMAT_E4X"/>
    Be sure to add the UtilNamespaceHandler to the application context.

    regards,
    Christophe
    Christophe Herreman
    Spring ActionScript Founder
    http://www.herrodius.com

Posting Permissions

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