Announcement Announcement Module
Collapse
No announcement yet.
Inject static property Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Hi there,

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

    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

    Comment


    • #3
      Awesome! Thanks!
      J

      Comment


      • #4
        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

        Comment

        Working...
        X