aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes MVC GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "MVC GUI" Watch "MVC GUI" New topic
Author

MVC GUI

Cecilia Anderson
Greenhorn

Joined: Nov 11, 2001
Posts: 13
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17228
    
    1

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Cecilia Anderson
Greenhorn

Joined: Nov 11, 2001
Posts: 13
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??

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17228
    
    1

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
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
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
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.
 
subject: MVC GUI
 
Similar Threads
MVC question
MVC pattern for GUI
Design Pattern Question
How Spring and Hibernate pair up?
Separation of Presentation and Logic