• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S Column Names

 
Samuel Pessorrusso
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in doubt about my TableModel. I'm trying to make the GUI independent of database columns, but in my DB interface there isn't a "getSchema()" method. So I'm having a trouble in discovery the columns names in order to show in them my JTable.

I was thinking in a solution� I�m thinking about creating a new Interface that extends the DB interface and that defines a �public String[] getSchema()� method. My Data class would implement this new interface.

Can I do that? Does any one know a better solution?

Thanks
 
Andreas Rutvik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Samuel.

If I have understood correct what you mean, this is a solution :



Regards
/Andreas
 
Samuel Pessorrusso
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My DB interface does not have the "getFieldInfo()". That's why I'm planing to extend the DB interface and add more methods.
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Samuel,

You should ask yourself the question if you want to use the field names from the database as column headers in your GUI in the first place. By mere incident, the names in the supplied files are quite readable. But imagine that the database designer had opted for field names such as CntrNm or numEmployees, would you still want to show these in your GUI?

Let your GUI layer determine the look of your application!

Frans.
 
Samuel Pessorrusso
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very good point! I didn't realize that.
But I still use the database column names and take as an assumption that database column names will be feasible enough to be used in GUI. That will make my application more flexible.
 
Lara McCarver
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really is a bad design to use database column names in the GUI. One improvement on using database column names is to use a resource file in your GUI. In Java, resource files map one string to another. So, you can use the database column names in this file, and map them to the display string.

Here is some code from a resource file which I am currently using (not for the SCJD project, for something at work)



So instead of using "CM_LABEL_ACTIVE", you would use "CustomerID" and map it to "Customer ID". Your GUI app could search for the resource, and only use the database name for the column if you don't find it in the resource file. You could even automatically add a help label which is mapped to help text about the column, i.e. "CustomerID_HELP" could map to a string which explains the required format of the customer ID. Again, you could automatically search for this.

I don't think you need to do any of this for the assignment, just a suggestion if you want to do it the way you are proposing.
 
Samuel Pessorrusso
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, i understood. I'm going to make a resource file and my application will search for the column name in this file. If it does not find the mapped string then it will user the real column name.

Thanks for your attention and help!
[ July 22, 2005: Message edited by: Samuel Pessorrusso ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic