• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

B&S Column Names

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic