This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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.