Announcement Announcement Module
No announcement yet.
Passing data from Command to Model Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing data from Command to Model

    I think it is a good idea to decouple Command and Model. Wondering what is the best way to pass data from Command to Listeners (could be any number of Models )?

    Thought of creating custom events to include the result and original event. Is this an overkill?

  • #2
    What do you mean by "command" in this case? If you are referring to the command object used in the following...

    <form:form commandName="myCommand">
    ...then the command is the model.


    • #3
      actionscript Commnad

      No I mean actionscript Command, implementation of ICommand


      • #4
        Oh, I haven't done Flash coding for eight years, and I suspect they might have changed it since then!


        • #5
          I'm not sure if I understand your question correctly but I'll try to answer anyway.

          In Spring ActionScript the ICommand interface is used in 2 scenarios:

          1. synchronous: in that case the resulting data of your command can be made available by returning it in the execute() method, since the methods return type is * (any type).
          2. asynchronous: in that case it is encouraged to implement IOperation (extends AbstractOperation). The result data can be made available via the result property of the COMPLETE event. You need to dispatch this yourself though. If you extend AbstractOperation, there is a convenience method that lets you pass in the result.

          You can then listen for that event and read the result from the OperationEvent.



          • #6
            Are you looking for something like this:

            The idea is that view passes its own IResponder (called view responder) and passes it to the ICommand+IResponder through the CairngormEvent. Then after the IResponder handles the result/fault, it calls the result/fault of the view responder.