since the method in the controller is calling a GUI method,
My question is: since the method in the controller is calling a GUI method, how couls we execute this
piece of code in Controller class? Or should we reverse this?
Originally posted by Sai Prasad:
Your myBoxActionMethod(), calls the appropriate method to search and get the search results in the form of DataInfo. Now you need to convert the DataInfo array to Object and set this array to your table model which is contained in the controller.
In other words, your table model is encapsulated in the controller and it has a method setData(Object) to populate the JTable to show the flight search results.
From your controller, if you want to communicate to the GUI to get or set any values, provide the appropriate methods in the GUI and try to communicate using only the String or Object objects. That way the GUI is not architecture dependent.
Now you need to convert the DataInfo array to Object and set this array to your table model which is contained in the controller.
Originally posted by Gosling Gong:
did you hardcode the title string of the table,
or stripe it from the DataInfo, which means we have to use DataInfo as parameter to TableModel rather than String.
So of the four methods outlined none seem to be perfect.
Originally posted by Robin Underwood:
You could do #1 without the controller knowing about GUI components. The controller could send a ready-made action listener (with controller methods) to a set method in the GUI. The GUI could then set the action listener for the appropriate GUI components.
John wrote (and I formatted):
1. Using the hook method means that the Controller has explicit knowledge of each component
that exists on the GUI (as there is a hook method for each GUI component).
Surely this cant be good??
2. The other option is to register a single event listener and have a number of if statements
in the Controller to figure out the event called( doesnt seem perfect either but possibly preferrable!!).
3. either the GUI event listeners have explicit knowledge of which method to call in the Contoller
(which we dont want either !!) or
4. else a generic event handler is called but this will need some way of figuring out the event executed
( means possibly using a set of static int's or whatever to match the event caught in the GUI, pass
this int in the call to the Controller event handler and then execute a Controller method based on
the value of the int ).