Hi! I am trying to implement the MVC pattern for the client GUI but I am not sure how to. For instance....is the Data class part of the Model or the Controller?? What methods should be included in the Model/Controller?? //Cecilia
Well that Data class, or better yet the DataAccessFacade, which has an instance of your DataAccess Interface is the Model. The controller should know about this Model, have a reference to it. Always think of Model = data, View = GUI, and Controller is the one that handles the GUI Actions and passes it to the Model, and when the Model changes the Controller passes the changes to the View. If you look at the JTable and understand the AbstractTableModel, and how it all works together, you will see an great example of MVC. Here is the JTable Tutorial at Sun. Hope that helps. If you need more clarification we are here. Mark
According to the diagram at for J2EE Design Patterns MVC the View makes a "state query" request to the Model and gets a "change notification" back. However you said that when the Model changes the Controller passes the changes to the View. Who is responsible for updating the View??
Yes. Both really. Because you can have handlers like what you have to fire a "Model has Changed" or you can the controller call a method on the Data, get the data, pass it to the View, and the View changes. There are times when you use one or the other. Mark
Beny Na
Ranch Hand
Joined: May 26, 2004
Posts: 159
posted
0
hi Mark,
Always think of Model = data, View = GUI, and Controller is the one that handles the GUI Actions and passes it to the Model, and when the Model changes the Controller passes the changes to the View
i still learn on how to work with mvc for my scjd. From my understanding about mvc is : when the model changes(by user action-->to controller), then the model itself will notify one/all of the registered observer/s to GUI, Not the controller passees the changes to the view. Pls correct me ... Registered observer, e.g JTable
And i am having a trouble when trying to apply mvc over the network with my current understanding since server have to notified observer/s thru network and design become complicated somehow.
pls give me some advice thks
Mihai Radulescu
Ranch Hand
Joined: Sep 18, 2003
Posts: 912
posted
0
Hi
I think that you mix a little bit the things, Everything is happen on the client side, you don't need notified observer/s thru network. Is something like :
Regards M
SCJP, SCJD, SCWCD
Beny Na
Ranch Hand
Joined: May 26, 2004
Posts: 159
posted
0
thks mihai,
you don't need notified observer/s thru network
yes in this assignment we dont have to notify observer thru the net, but on my design(local mode), gui component such as Jtable will registered as an observer to the model. code
sorry i can't describe my code clearly, hope you can get my idea from the code above. the code above is what i have done so far by implementing the mvc pattern on local mode. is it right? Pls help me, thks
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.