tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/560-injector-is-missing-a-rule-to-handle-injection-into-targetRobotlegs: Discussion 2012-04-26T16:09:52Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/155841962012-04-26T15:55:03Z2012-04-26T15:55:03ZInjector is missing a rule to handle injection into target<div><p>Hello,</p>
<p>What does constructor of BoundingBox look like? The injector is
saying that it doesn't know how to provide the first constructor
argument of BoundingBox (which is a Number) when it tries to
construct it.</p>
<p>Also, your command has a dependency on BoundingBox, yet it also
maps BoundingBox as a singleton when it executes. Have you mapped
the BoundingBox elsewhere, and are you intending to overwrite the
mapping in the command?</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/155841962012-04-26T15:58:38Z2012-04-26T15:58:38ZInjector is missing a rule to handle injection into target<div><p>Just spotted that I left in the extra injection in the command,
didn't mean to leave that in, I was experimenting, I've edited it
now, thanks for the spot Shaun.</p></div>jeremy.brookstag:robotlegs.tenderapp.com,2009-10-18:Comment/155841962012-04-26T15:59:42Z2012-04-26T15:59:42ZInjector is missing a rule to handle injection into target<div><p>The bounding box constructor looks like this;</p>
<pre>
<code> public function BoundingBox(minx:Number, miny:Number, maxx:Number, maxy:Number, srs:String = "EPSG:4326"){
_minx = minx;
_miny = miny;
_maxx = maxx;
_maxy = maxy;
_srs = srs;
}</code>
</pre></div>jeremy.brookstag:robotlegs.tenderapp.com,2009-10-18:Comment/155841962012-04-26T16:06:15Z2012-04-26T16:06:15ZInjector is missing a rule to handle injection into target<div><p>Shaun, you sparked an idea there, so instead of using
mapsingleton I've used mapValue, providing a default object, worked
great, thanks!</p>
<p>injector.mapValue(BoundingBox, new BoundingBox(0,0,0,0));</p></div>jeremy.brookstag:robotlegs.tenderapp.com,2009-10-18:Comment/155841962012-04-26T16:09:27Z2012-04-26T16:09:27ZInjector is missing a rule to handle injection into target<div><p>Aha, that's the problem right there :)</p>
<p>The injector has no idea how to create an instance of
BoundingBox - it doesn't know how to provide any of the constructor
arguments. You have a couple of options:</p>
<ol>
<li>Make all the ctor arguments optional (with default values)</li>
<li>Provide the instance yourself when doing the mapping:
<code>injector.mapValue(BoundingBox, new
BoundingBox(7,5,90,90));</code></li>
</ol></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/155841962012-04-26T16:09:51Z2012-04-26T16:09:51ZInjector is missing a rule to handle injection into target<div><p>You beat me to it :)</p></div>Shaun Smith