This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes MVC + Nickers in twist :) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "MVC + Nickers in twist :)" Watch "MVC + Nickers in twist :)" New topic
Author

MVC + Nickers in twist :)

Colin Yates
Ranch Hand

Joined: Dec 16, 2004
Posts: 31
All,

I think I am getting a bit too obsessed with tis whole MVC thing.

First off, I have a mainGUI which displays search criteria and search results. I expose the buttons and search criteria (combos) via getters. In my controller I add a listener to the button and then call my facade.search(criteria[]).

All well and good.

I also have a reservationGUI which displays a single record and allows you to book it. I have a reservatonController and reservationModel. The mainController will construct a new reservationController everytime you click the reserve button (assuming you have selected a row in the table).

OK, all standard stuff.

Now my questions

The reservationGUI should start off disabled until it has acquired a lock. The reservationModel fires events which the GUi listens to (i.e. recordLocked()). Should the controller listen to these events and then enable/disable the relevant components on the reservationGUI, or should the GUI itself? It seems to be more of a GUI thing to me?

The reservation code has some validation logic associated with it, i.e. it has to be between 1 and 8 characters long. Should the controller add a listener onto the field and enable/disable the button, or should the GUI doe this by default?

After the reservationGUI closes, assuming they have booked the reservation, how does the mainGUi get updated? Should the mainGUI also listen to every instance of reservationModel, or should the mainController listen?

The question really is how much logic goes into the GUI? On the one hand you could write a GUI which is very self contained, and exposes implementation agnostic aware methods like String[] getCriteria() and onReservationEvent(int selected rowNo), or you could have an incredibly dumb GUI which does nothing more than layout components. In this case the controller must then add logic (i.e. validation logic, actionListeners etc) to the GUI and the GUI must expose all of it's internal workings.

Help The consensus seems to be to have an incredibly dumb GUI and make the controller *very* aware of the GUI's internal workings.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: MVC + Nickers in twist :)