How should i access model inside a command ?
hi!
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.
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 ?
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Stray on 10 Jun, 2012 12:41 PM
Hi Vishwas,
you should be able to inject the model inside the command.
2 questions:
1) Did you make the variable public?
[Inject]
public var someModel:SomeModel;
The injector can't inspect private / protected members.
2) Did you definitely have your
[Inject]
tag correct?
All of these will fail:
[inject]
[INJECT]
[inJect]
[Inject]; (Putting a semi-colon between the tag and the `public var` declaration breaks the association).
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.
Stray
3 Posted by vishwas.gagrani on 27 Jun, 2012 01:39 PM
ok, thanks
I used "private" specifer. Replacing it with public solved the problem.
Ondina D.F. closed this discussion on 28 Jun, 2012 09:16 AM.