| Author |
NX: Where TableModel goes? -- Client GUI
|
Rick Lu
Ranch Hand
Joined: Mar 25, 2003
Posts: 47
|
|
HI, In my design, two JComboBox (Views) are hooked with DataModel (Model) (client side) through listeners. Controller (Control) deals with all inputs from JComboBox and JTable, then directly save all changes in the DataModel (Model). But the question is where I should put TableModel? I consider it as the part of Views in MVC. But according to this, I cannot hook it with DataModel (model), right?. And I have no idea how to update it by View ( bypass Controller or not???) ? Any suggestion for this? Thanks. Rick Regards.
|
SCJD 1.4
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10816
|
|
Hi Rick,
Originally posted by Rick Lu: But the question is where I should put TableModel? I consider it as the part of Views in MVC. But according to this, I cannot hook it with DataModel (model), right?. And I have no idea how to update it by View ( bypass Controller or not???) ?
I agree with your idea of having the TableModel within the view. You could have the View getting the updates from the Model and passing them on to the TableModel. Alternatively, if your Model is Observable, you could make your TableModel an Observer, and have it receive the updates directly. Does this give you some ideas? Regards, Andrew
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Rick Lu
Ranch Hand
Joined: Mar 25, 2003
Posts: 47
|
|
Thank you, Andrew.
You could have the View getting the updates from the Model and passing them on to the TableModel.
I think JTable is the View. But of course, I need a class (TableModel) that extends AbstractTableModel. My question is that how I can update TableModel by View? Did you mean directly getting updates from Model to JTable and passing them to TableModel? Or something else? I cannot understand this. Currently, the view - JTable gets everything from TableModel. Could you explain this from me? Confused. Regards. Rick
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10816
|
|
Hi Rick, You have some class that sets up the TableModel and the JTable. That class could either pass updates from the Model to the TableModel, or it could register the TableModel as an Observer of the Model (in which case the TableModel will get the updates automagically). Regards, Andrew
|
 |
Rick Lu
Ranch Hand
Joined: Mar 25, 2003
Posts: 47
|
|
Hi Andrew,
You have some class that sets up the TableModel and the JTable. That class could either pass updates from the Model to the TableModel,
You mean "That class" is a part of Views? To me, the role of it is not clear. I think that's my problem. Is it a part of View?
or it could register the TableModel as an Observer of the Model (in which case the TableModel will get the updates automagically).
Yes, I currently use it and it works. Thanks. Rick
|
 |
Rick Lu
Ranch Hand
Joined: Mar 25, 2003
Posts: 47
|
|
I think I undertand your points now, Andrew. Thanks. Rick Regards.
|
 |
 |
|
|
subject: NX: Where TableModel goes? -- Client GUI
|
|
|