Dependency Injection
Comments
If you add bind then Swiz creates a binding between the property you're injecting into and the source property (as if you set up a binding yourself using the Flex BindingUtils class). Without bind (which is the default), it doesn't create a binding. If you're not familiar with what this actually means, you may want to read through that section of the Flex documentation.
Destination can be useful if you want to inject (and potentially bind) directly to a component property, rather than having to declare your own property, inject into it, and then bind some other component property to your own property. Basically, I haven't found much use for it so if that isn't clear, I really wouldn't worry about it. As the note above says, you have to be careful with destination because the destination may still be null (if Flex hasn't created that component yet).
Sad, I can't get anything sample swiz project to work with Flex Builder 3, SDK 3.5.
I tried the simplest feature of Swiz, inject a model object into the main app and into a view componenet.
Neither of them get the model injected, they remained null.
Can someone please help?
Just give a sample flex 3 app that uses the latest Siwz 1.0-RC1 with no services, just model injection for now.
Thanks,
If you have a question, please post it to the mailing list, that's what it's there for. Thanks.
where is the the mailing list?
It's listed on the wiki home page, in the FAQ, and on the left sidebar of every page on this wiki.
in spring. we can inject collections like(list map)
such as below:
<beans>
<bean id="someBean">
<property name="someArray">
<list>
<value>Hello!Justin!</value>
<value>Hello!Momor!</value>
<value>Hello!Bush!</value>
</list>
</property>
<property name="someObjArray">
<list>
<ref bean="someObj1"/>
<ref bean="someObj2"/>
</list>
</property>
<property name="someList">
<list>
<value>Hello!Justin!</value>
<ref bean="someObj1"/>
<ref bean="someObj2"/>
</list>
</property>
<property name="someMap">
<map>
<entry key="somekey1">
<ref bean="someObj1"/>
</entry>
<entry key="somekey2">
<value>Hello!Justin!</value>
</entry>
</map>
</property>
</bean>
</beans>
there are just [Inject metadata tag] in swiz and it can't inject more than two beans(Config in the BeanProvider) into an ArrayCollection property. Would you please give me some adives if I want to function.
Spring is configured with plain XML. Since Swiz BeanProviders are actual MXML declarations of classes, you can specify properties the same way you would in any other MXML code. So your Spring configuration code above could be used simply as:
<model:MyBean id="someBean" somearray="{['Justin','Momor','Bush']}" someObjArray="{[someObj1,someObj2]}" ....etc.... />
thanks!
It sounds good. but how about inject the flash.utils.Dictionary(like a map)
You'd do it the same way, either referencing an existing Dictionary or creating a new instance when you set the property. If you have more questions, feel free to ask on the mailing list (see link on the left). We're trying to keep the wiki comments specific to the documentation. Thanks.
I was once aware of the difference between [Autowire] and binding.. However the difference between [Inject] with bind property to [Inject] without and the meaning of the new destination property makes it unclear to me.... This creates a mixup between what Swiz does and what the flex binding mechanism does.