tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/4684-injection-not-workingRobotlegs: Discussion 2013-09-23T14:34:28Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/282980662013-08-16T16:39:30Z2013-08-16T16:40:05ZInjection not working :(<div><p>Greetings,</p>
<p>I am new to RobotLegs (i.e have never used RL1) and I am having
troubles with injection. I have read the common mistakes section
and followed all the advice there but still I cannot inject. I am
trying to inject a code behind class into a view to provide a click
event handler function to a LinkButton but it seems no matter what
I do the injected instance is always null. Can anyone here
assist?</p>
<p>My current Additional Compiler Arguments are as follows:<br>
-locale en_US -source-path=locale/{locale}
-keep-as3-metadata+=Inject -keep-as3-metadata+=PostConstruct
-keep-as3-metadata+=Execute -keep-as3-metadata+=Payload
-define=APP::version,0.0.0 -define=APP::build,0</p>
<p>I have verified that the case of my [Inject] tags are correct
and not followed by a semicolon.</p>
<p>As a side note, I don't seem to be able to get the PostContruct
meta tag to work either. I feel like I must have missed some key
bit of information along the way. I would be happy to provide a zip
of the code to anyone willing to assist.</p></div>ericwfishertag:robotlegs.tenderapp.com,2009-10-18:Comment/282980662013-08-17T07:17:04Z2013-08-17T07:17:04ZInjection not working :(<div><p>Hey Eric,</p>
<blockquote>
<p>I would be happy to provide a zip of the code to anyone willing
to assist.</p>
</blockquote>
<p>Yes, please attach the code, I'll take a look at it.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/282980662013-08-17T15:51:25Z2013-08-19T10:44:47ZInjection not working :(<div><pre>
Ondina,
Please find the project attached. Here is what is happening...
When Launching the application you will see a "Login" LinkButton at the top right of the stage. If you click on this button you get an exception because the injected codebehind class LoginButtonCB) is null.
For your reference, the code in question exists in the following package:
com.fsllc.plexus.components.auth
You will also notice through inspection that the injected model class is also null. Additionally, I attempted to create PostConstruct methods in a variety of different places but I never hit break points set in those methods. It appears to me that the only injection that actually works is that of the Injector class itself. I am very perplexed. Have I missed some key piece of information to set up the project correctly or something like that?
My environment is:
Flash Builder 4.7
Apache Flex 4.10.0
RobotLegs 2.1.0
I have tried several variations on RobotLegs versions and Flex SDK versions as well.
Thank you very much for taking the time to assist. O look forward to learning what you discover.
Eric
</pre>
<p>I found the culprits:)</p>
<p><strong>1</strong> you forgot to add ContextViewListenerConfig
to the configurations.</p>
<p>ContextViewListenerConfig - adds the contextView to the
viewManager. Without it there is no contextView and any view added
to the contextView won't be processed.</p>
<pre>
<code>context = new Context()
.install(AppBundle)
.configure(AppConfig)
.configure(AuthConfig)
.configure(ContextViewListenerConfig, new ContextView(this));</code>
</pre>
<p><strong>2</strong> ViewProcessorMapExtension - allows direct
view processing (e.g. direct injection) [<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/viewProcessorMap">https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a>]
So, in your AppConfig you inject it:</p>
<pre>
<code>[Inject]
public var viewProcessorMap:IViewProcessorMap;</code>
</pre>
<p>and then you use it like this:</p>
<pre>
<code>injector.map(AppModel).asSingleton();
viewProcessorMap.map(AuthViewBase).toInjection();</code>
</pre>
<p>Your app is now working on my end. Let me know how it goes for
you.</p>
<p>Ondina</p>
<p>P.S. You can delete the attachment (if you want to) and mark the
discussion as public</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/282980662013-08-17T21:00:12Z2013-08-17T21:00:12ZInjection not working :(<div><p>Ondina,</p>
<p>Thank you very much for your assistance! It is kind of hard to
to make heads-or-tails out of the RL2 documentation without
previous knowledge of RL1. I was looking at a variety of different
examples using different versions of RobotLegs trying to figure out
what I was missing. Thanks again for pointing me down the correct
path.</p>
<p>Do you know if there is any work planned around RL2
documentation outside of the markdown files? Just curious.</p>
<p>I didn't realize that I had created a private post. I'll change
that.</p></div>ericwfishertag:robotlegs.tenderapp.com,2009-10-18:Comment/282980662013-08-19T10:48:44Z2013-08-19T10:48:44ZInjection not working :(<div><p>You're welcome, Eric!</p>
<blockquote>
<p>It is kind of hard to to make heads-or-tails out of the RL2
documentation without previous knowledge of RL1.</p>
</blockquote>
<p>True. You'll have to read at least the Best Practices, written
for RL1, to understand the basic principles.</p>
<blockquote>
<p>Do you know if there is any work planned around RL2
documentation outside of the markdown files? Just curious.</p>
</blockquote>
<p>I don't know if Shaun or creynders are planning on writing a
tutorial.<br>
I am working on a step by step demo, but there are 2 major problems
I'm facing: lack of time and poor English skills. English is not my
native language and I find myself struggling with words more than
necessary, probably because I think a tutorial requires a high
level of clarity in a compact form, while, at the same time, all
common scenarios are being handled.<br>
But, I think I'm overanalysing and overcomplicating things, I'll
just upload my scribbles on github and wait for it to explode
;)</p>
<p>This is kind of a burlesque attempt at a tutorial (first draft
and not even finished):</p>
<p><a href=
"https://github.com/Ondina/robotlegs-bender-modular-air/wiki/Robotlegs-2-Context">
https://github.com/Ondina/robotlegs-bender-modular-air/wiki/Robotle...</a></p>
<p>I'll try to find some time to finish the step by step demo +
serious tutorial, at least the part for creating a Context.</p></div>Ondina D.F.