How should i access model inside a command ?

vishwas.gagrani's Avatar

vishwas.gagrani

10 Jun, 2012 12:31 PM

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 ?

  1. 1 Posted by Stray on 10 Jun, 2012 12:41 PM

    Stray's Avatar

    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

  2. 2 Posted by vishwas.gagrani on 27 Jun, 2012 01:39 PM

    vishwas.gagrani's Avatar

    ok, thanks
    I used "private" specifer. Replacing it with public solved the problem.

  3. Ondina D.F. closed this discussion on 28 Jun, 2012 09:16 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac