Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Table Model Location

 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Where shall I put Table Model? is it in the server or the client? and why?
Max in his book put it into the client???
Regards
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Qusay,
I read Max's book too and I asked myself the same question.
I have not decided yet, but at first sight it seems to me that it's better that the server serves data in a generic way, making as few assumptions as possible about how a client might want to present and format the data.
Any comment will be appreciated, I am confused too.
Regards,
Phil.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The TableModel resides with the client. It is not part of the db, but it is part of the JTable. This is MVC. It is the Model to the view.
Mark
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark and Max are correct: the TableModel should be client side.
The TableModel is used specifically by the JTable. So if you had the server providing a TableModel, then ALL clients that ever connect to the server will have to implement a JTable to work with the data (or do extra work to try and get the data into a format that it can use).
So putting the TableModel on the server side severely limits what sorts of clients you can build in the future.
Regards, Andrew
 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, that's so clear
 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When writing the code for TableModel in the client side, need to connect to the server in order to get Table header names, or shall I write an array of Table header names and that's all (in this case any change into the database in the future need to change TableModel too...
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Qusay
I think it is better to get the column names from the database. They are there, so you might as well use them. This makes it easier to handle any changes later.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic