I am using the Asp.NET MVC Framework, using CometD as a client for receiving new data from time to time. I listen for this data and add it to my database in a repository. Now I asked myself - how can I inform a particular view or model about the fact, that new data is available?
Thanks very much for your help!
开发者_运维问答Chris
Views are stateless. That is, the data they use is the data as it was at the point in time the View was generated, and that's it.
Once a view is rendered, it is sent back the the browser as a regular html page. To recieve push notifications via ajax using something like CometD, you would need to code something in the client side code (or however CometD does it)
The controller that recieves new data and updates the repository would be responsible for pushing the new data out to listening clients. But it would not be the MVC view that does the receiving (because views are rendered server side), it would be JavaScript running in a client browser.
Hope this helps.
精彩评论