aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes MVC: Model notifying View Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "MVC: Model notifying View" Watch "MVC: Model notifying View" New topic
Author

MVC: Model notifying View

David Follow
Ranch Hand

Joined: Oct 16, 2001
Posts: 223
Hi all,

understanding one major part of the MVC pattern, that views register to the model and as soon as the model changes, the model notifies all registered views -> Observer Pattern.
Now I am wondering how this can happen in a 3 tier architecture. I know there is such thing as MVC2 for Web based apps with JSPs as view, a servlet as controller and EJBs as the model. But how will the MVC pattern work in a Swing based app with the model being remote EJBs? How can a view in such a scenario register to the model and how will the (remote EJB) model be able to notify chances to the registered views?

Any ideas are welcome!

D.


SCJP, SCEA
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
There are a couple ways to look at this.

One is to say the Swing client has the complete MVC inside it, and remote communications are something the model does when it has to. That makes remote communications unrelated to the client MVC. Oh, I almost passed up a chance to say "orthogonal". The server can have another complete MVC model inside as well, if you like.

It's more complex to imagine remote communications between MVC components. You could try to just ignore the remote aspect and have the components talk to each other as usual. For server to talk to client asynchronously (say as a result of a server event, not a client request) it would have to have a socket or some connection to push data. Unfortunately, ignoring the remote aspect leads us to design overly busy network communications, so we probably don't want to go there.

I'd love to make up a third answer that perfectly balances all your concerns, but I have to go watch a movie with the wife. And I don't know one. Did those thoughts mesh with what you're trying to do?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: MVC: Model notifying View