Announcement Announcement Module
Collapse
No announcement yet.
Autowiring of Properties (Not objects) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Autowiring of Properties (Not objects)

    Is there currently a way to autowire properties rather than objects? Eg:
    applicationContext.xml
    Code:
    <property file="context.properties"/>
    context.properties
    Code:
    myProperty = 12345
    SomeClass.as
    Code:
    [Autowired(propertyName="myProperty")]
    public var myStringProperty:String;
    Is there an equivalent of this in Spring Actionscript that I'm unaware of? It'd sure be nice to inject String variables this way

  • #2
    Is there even a way to do this without autowiring? I need to externalize a few properties (like locations of images for example), so how should I do this? If I try creating these values as literal String typed objects in my application context, and try to autowire these, nothing happens, my properties are not set in my class. Eg:
    Code:
    <!-- applicationContext.xml -->
    <object id="myProperty" class="String">
        <constructor-arg value="my proeprtyasdfawefasdf"/>
    </object>
    Code:
    <!-- application.mxml -->
    <fx:Declarations>
       <!-- shortened for brevity's sake :) -->
       <ioc:FlexXMLApplicationContext id="applicationContext"/>
    </fx:Declarations>
    
    <fx:Script>
      ...
      [Autowired(name="myProperty")]
      public function set myProperty(value:String):void {
          throw new Error("it works!");
      }
      ...
    </fx:Script>
    Running the code snippet above will result in no error being thrown (an error should be thrown when the myProperty property is set.)

    Comment

    Working...
    X