tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/372-inject-non-actor-classRobotlegs: Discussion 2011-11-02T17:01:04Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/98650302011-09-09T22:59:31Z2011-09-09T22:59:31ZInject non Actor class?<div><p>Hi Jason,</p>
<p>yes, that should work - as long as the class where the
[Inject]... code is will be created using the injector.</p>
<p>What kind of class are you injecting into? And how does that
class get created? If you just do</p>
<p>new Thing()</p>
<p>The injector won't have had a chance to process that class to
give it the injections.</p>
<p>I suspect this is the cause of the problem.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/98650302011-09-09T23:15:53Z2011-09-09T23:15:53ZInject non Actor class?<div><p>Here is what I have.</p>
<p>My application has it's Context class which calls in the
onRegister method</p>
<pre>
<code> injector.mapSingleton(EntryDataService);
//map service
injector.mapSingletonOf(IApprovalService,ApprovalService);</code>
</pre>
<p>EntryDataService is an existing class we have that extends the
Flex DataService class which we want to avoid wrapping this class
in an Actor if possible.<br>
When ApprovalService gets called via the ApprovalCommand class
which is also mapped in the onRegister.</p>
<p>ApprovalService has the following.</p>
<pre>
<code>[Inject]
public var entryDataService:EntryDataService;</code>
</pre>
<p>When the ApprovalCommand calls the method getApproval() the
entryDataService is null, so I put a breakpoint in the constructor
of EntryDataService never getting instantiated.</p></div>Jason Grahamtag:robotlegs.tenderapp.com,2009-10-18:Comment/98650302011-09-09T23:21:22Z2011-09-09T23:21:22ZInject non Actor class?<div><p>Hi Jason,</p>
<p>There are only a limited number of reasons why this could happen
- either your injection point is broken and actually is private,
'Inject' is misspelled or something similar, or your metadata is
being stripped out.</p>
<p>As the ApprovalService is being injected into the Command ok, we
can pretty much rule out the metadata problem.</p>
<p>If your injection wasn't mapped properly then you'd get an
injector error. So, most likely your [Inject] tag is broken.</p>
<p>Check through the common problems document (link is on the right
on the front page of the forum) for a list of things to look out
for.</p>
<p>If you wan't to paste the actual code in then that could be
useful.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/98650302011-11-02T17:01:01Z2011-11-02T17:01:01ZInject non Actor class?<div><p>Jason,<br>
Feel free to reopen this discussion in case you have more questions
or you need further assistance with this issue. Please open new
threads for new issues.</p>
<p>Ondina</p></div>Ondina D.F.