Skip navigation
Currently Being Moderated

Passing data from the command

Feb 25, 2010 10:07 AM

Hey im new to cairngorm

How do i pass data back from the command ie from the onResult() in the command back to the component the called it

I know how to put the data in the model, but it is my impression that this is only for data that you want to store and reference in many places

with i have done with some querys

 

This query however is just a product search result so don't need it to be stored in the model just sent back and displayed in a grid

 

Thanks

 


 
Replies
  • Currently Being Moderated
    Feb 25, 2010 10:54 AM   in reply to JockMahon

    There's no inbuild facility to reach views from within Commands in C3 Integration lib, nor in Parsley 2.2. You could of course inject them into Commands. However, I don't see the extra effort in separating your concerns slightly better and creating a model, do you?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 1, 2010 6:05 AM   in reply to JockMahon

    Yes, I would probably favour creating a model in most real-world cases. Check out the tutorials and sample apps in the Introduction section of the Cairngorm guidelines to learn more.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2010 3:52 AM   in reply to JockMahon

    Yes I am having a similar problem.

     

    I need the UI to respond to data being loaded. I know I can Bind data and all of that but I don't need to display the data I just want the interface to change once the data has loaded.

     

    Obviously if I was doing this from scratch I would trigger an event the the GUI listens for but how do I do that from a controller??

     

    Any ideas

     

    Thanks

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2010 4:30 AM   in reply to JockMahon

    OK,  I have done some looking around and found a possible solution. I am not sure if its pure Cairngorm or MVC but it seem to work for me so here we go

     

    You can have more than 1 Model. You can have as many as you require grouping you data in logical collections. These should always be Bindable.

     

    Then in my case You have a creationComplete event in you main application file that tells a command to load data in the usual Cairngorm way. This data is then passed to and ArrayCollection in the Model

     

    What I am then doing (rightly or wrongly) is adding an event listener in the main app file that listens for the ArrayCollectio to change (CollectionEvent.COLLECTION_CHANGE) and then trigger another event.

     

    I suppose you could get more complex and have a Boolean variable in the Model that just states if data was loaded correct and the app file listens for that to change.

     

    I guess I am treating the concept of Models as not just a place to store your data but also all variables that need to be globally accessed. As I said I have now idea if this is proper MVC or the correct use of Cairngorm but it works for me.

     

    I hope that’s clear and not just a load of garbage ;-)

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2010 5:26 AM   in reply to JockMahon
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 16, 2010 3:13 AM   in reply to JockMahon

    Yes I agree. I also would have thought it would be an issue that more people would face than there seem to be.

    I have heard critism that Cairngorm relies too much on Data Binding. I guess many developer just listen for data changes to notify the View but like you said this seem a little cluncky to me and can soon become very complex.

     

    Anyway glad I could help a little bit.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points