It's not a secret anymore!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes For Max: Controller in MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "For Max: Controller in MVC" Watch "For Max: Controller in MVC" New topic
Author

For Max: Controller in MVC

S. Ganapathy
Ranch Hand

Joined: Mar 26, 2003
Posts: 194
Hi Max,
How was your trip, and How was the seminar?
OK. I want some info regarding MVC. I want to know the role of controller in MVC architecture. Is EventHandler a controller?
In my assignment, I am handling UI events in two classes(ActionEvents is one class, and mouse events in another class). Are these two controllers, or the one which is responsible to retrieve TableDataModel is controller?
Please clarify my doubt.
In your book, controller is different. All events are handled in inner classes in MainWindow.java.
Thanks in advance.
Regards,
Ganapathy.
[ May 29, 2003: Message edited by: S. Ganapathy ]
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
The talk was great: it was in Papanal, which is an Olympic training facility outside of Anheim.
Regarding your question. Are you asking what a controller is, conceptually, or specifically? Conceptually, a controller is something that takes direction from the client, and 'decides' what the client really wants. For example, a waiter in a restaurant is a controller, because they 'decide' what you mean when you say you want your steak to be medium rare.
Similarly, a controller decides what views the client should see: going back to the waiter example, the waiter might decide you're the head of the table, so you get the menu with prices on it, or that the children at your table get kiddie menus.
The point here is that controller provide access to a system, and they can work together. Thus, the kitchen's controller(the chef), might interface nicely with the waiter.
Very nice, but what's my point? The point is that eventHandler you're talking are controllers, but they don't have to be the only controllers. They might interact with another layer, say a Controller interface, that actually talks to the back end.
Make sense?
M


Java Regular Expressions
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

"Make sense?
M"
I don't know if it makes sense, but I am now really hungry. Can you get me a hamburger with some fries?
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
S. Ganapathy
Ranch Hand

Joined: Mar 26, 2003
Posts: 194
Hi Max,
Thanks for your response. I know the role of controller in MVC, but, I was in dialama whether I can use more than one class as controller.
In my GUI client, I am handling all ActionEvents in ActionEventHandler.java which is an inner class, and Mouse events in MouseEventHandler.java, etc. Also I am using GUIController.java to get TableDataModel, and doing some other needed functionality. Whether I can use these two or not, I was not very sure.
I should use as minimum classes as possible. It is the restriction.
In Database, I was given DBAccess interfasce.
Data.java is the implementer for that. LockManager is an inner class, has locking mechanism, and is called by Data.java.
DBAdapter.java(for standalone), RemoteDBClientImple.java(for RMI) implements client interface to fulfill the requirement.
And one ConnectionFactory.java to get local or remote connection. This is the database side.
Max, am I going in the right direction?
Please provide your comments and criticisms.
Thanks in advance.
Regards,
Ganapathy.
Thomas Kijftenbelt
Ranch Hand

Joined: Feb 13, 2002
Posts: 73
Max,
You probably mean Papendal (near Arnhem)...
TK (from Holland)
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
I do mean Papendal, sorry about the spelling. Had a little fright there too . I was running out there @ night and enjoying the beautiful trails, about 2 am, and saw a rabbit. No big deal: rabbits, right? But then, all of a sudden, I was convinced that where there are rabbits, there are wolves, and that one was going to jump out me. After that, it was quite the interesting night run
M
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
Originally posted by S. Ganapathy:
Hi Max,
Thanks for your response. I know the role of controller in MVC, but, I was in dialama whether I can use more than one class as controller.
In my GUI client, I am handling all ActionEvents in ActionEventHandler.java which is an inner class, and Mouse events in MouseEventHandler.java, etc. Also I am using GUIController.java to get TableDataModel, and doing some other needed functionality. Whether I can use these two or not, I was not very sure.
I should use as minimum classes as possible. It is the restriction.
In Database, I was given DBAccess interfasce.
Data.java is the implementer for that. LockManager is an inner class, has locking mechanism, and is called by Data.java.
DBAdapter.java(for standalone), RemoteDBClientImple.java(for RMI) implements client interface to fulfill the requirement.
And one ConnectionFactory.java to get local or remote connection. This is the database side.
Max, am I going in the right direction?
Please provide your comments and criticisms.
Thanks in advance.
Regards,
Ganapathy.

Oh, absolutely, and I think it's a good idea. Your controllers are logically divided for clarity: no problems with that.
M
S. Ganapathy
Ranch Hand

Joined: Mar 26, 2003
Posts: 194
Thankyou very much Max.
Regards,
Ganapathy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: For Max: Controller in MVC