wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Is right,MVC? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Is right,MVC?" Watch "Is right,MVC?" New topic
Author

Is right,MVC?

shao zhimin
Greenhorn

Joined: Aug 07, 2002
Posts: 16
I,m writting my GUI, but doubt that the MVC pattern. now i design three panel -- searchingPanel, bookingPanel and JTable, i have a question that searchingPanel bookingPanel is View or controller??
now i have a ActionController (but not implements ActionListener). searchingPanel and bookingPanel implements ActionListener. when an user event occur, its call the methods of ActionController. is it rigtht?? i only one controller?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Shao,

... i have a question that searchingPanel bookingPanel is View or controller??
now i have a ActionController (but not implements ActionListener). searchingPanel and bookingPanel implements ActionListener. when an user event occur, its call the methods of ActionController. is it rigtht?? i only one controller?

Your two panels exhibit traits of both view and control, which is very common for swing's idea of MVC. The view and control are usually tightly coupled. I would not worry too much about the exact semantics of your implementation so long as it is clear and functions well. I used a completely unorthodox approach for control, using a java.beans based Mediator pattern and scored perfect on the GUI. So, as long as your ActionControler is well designed and decouples the the two panels from your other GUI components you should not have anything to worry about.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
shao zhimin
Greenhorn

Joined: Aug 07, 2002
Posts: 16
thanks Michanel, but now i consider that the ActionController extends ActionListener and all the user event are dealed in the controller. i have another question that how to distinguish the different event?? use getActionCommand() methods or the other method?
the reason what i to do that i look some posts in the forum and someone use one Controller, but i do not well it.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Shao,
When I had multiple components using the same ActionListener, I used getActionCommand() from the ActionEvent to distinguish where the event originated. That's usually the simplest way and is perfectly accepatable.
Hope this helps,
Michael Morris
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is right,MVC?