• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

storing data in the table model

 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an AbstractTableModel for my JTable in the gui. This model also stores a copy of the search results as a DataInfo array. This seems bad to me because it ties the gui with the database. I was thinking of having my facade return a generic search results object that could separate these a bit. Basically it would just hold the DataInfo array and have getters to get at its data. But this would allow easy migration to new databases (if a switch to new database happened, a new SearchResults object would need to be created).
Anyone see any problems with this approach?
Thanks,
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, i am doing more or less the same.
my facade (flightData) has a couple of functions :
public String[][] getAllFlights() {....}
public String[] getColums() {}
my model is created in the controller as:
new SearchModel(String[] cNames, Object[][] data)
basically exactly as java - tutorial describes
every search changes the searchmodel and the controller loops though all views updating the models.
I hope it helps.
friso
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I think you want to keep knowledge of DataInfo and FieldInfo out of the GUI. See this link for why many points were taken off a GUI, including inability to browse another database:
http://www.coderanch.com/t/136528/sr/certification/Passed
[ July 29, 2002: Message edited by: Robin Underwood ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic