tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/606-how-should-i-access-model-inside-a-commandRobotlegs: Discussion 2012-06-28T09:16:15Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/165601032012-06-10T12:31:51Z2012-06-10T12:31:51ZHow should i access model inside a command ? <div><p>hi!<br>
I am not able to get, how exactly to access a model inside command.
If i remember correctly, in previous mvc pattern i followed there
was a direct access to model available inside the command. I tried
to inject model inside the command to access it :p , and it showed
me null.</p>
<p>I went through the example kanban application. There i can see a
service is created ( StubStatusService ) that extends Actor . The
model is injected there, and thus accessible. Is this the way
should i follow. Or is their some other shortcut ?</p></div>vishwas.gagranitag:robotlegs.tenderapp.com,2009-10-18:Comment/165601032012-06-10T12:41:30Z2012-06-10T12:41:30ZHow should i access model inside a command ? <div><p>Hi Vishwas,</p>
<p>you should be able to inject the model inside the command.</p>
<p>2 questions:</p>
<p>1) Did you make the variable public?</p>
<p>[Inject] public var someModel:SomeModel;</p>
<p>The injector can't inspect private / protected members.</p>
<p>2) Did you definitely have your</p>
<p>[Inject]</p>
<p>tag correct?</p>
<p>All of these will fail:</p>
<p>[inject] [INJECT] [inJect] [Inject]; (Putting a semi-colon
between the tag and the <code>public var</code> declaration breaks
the association).</p>
<p>Also - I assume the command is being triggered by an event on
the command map? If you just new() something up then it won't have
any injections fulfilled.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/165601032012-06-27T13:39:08Z2012-06-27T13:39:08ZHow should i access model inside a command ? <div><p>ok, thanks<br>
I used "private" specifer. Replacing it with public solved the
problem.</p></div>vishwas.gagrani