aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Is it possible to exclude certain columns from a prefilled object from the db module to a model? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is it possible to exclude certain columns from a prefilled object from the db module to a model?" Watch "Is it possible to exclude certain columns from a prefilled object from the db module to a model?" New topic
Author

Is it possible to exclude certain columns from a prefilled object from the db module to a model?

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598
Dear all,
In the code below, you see that some columns are excluded because they will not be needed somewhere
in my program (and somewhere else they are needed).
I would like to make a universal method so that it can be reused. But when I map these objects
to JTable using the constructor of DefaultTableModel, they somehow would include all columns that
are queried. Can I just exclude some of them to suit the JTable model where appropriate?
Thank you
Jack

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2419
    
    7

Would it better to not get those unused data from the Employee? The table model having the complete data from the table is somewhat a good thing because you never know when what is needed and when it's not needed.

K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598
Hello K Tsang,
K. Tsang wrote:
Would it better to not get those unused data from the Employee?

So I should use different SQLs + methods to present different JTable's?
Thanks
Jack
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2419
    
    7

To keep things simple I think you can keep getting all the columns for Employee class. But in the table model just get the attributes you need (eg overriding the getColumn() if I remembered correctly).

Since this is getting towards more Swing stuff, I shall move to that forum.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2183
    
    7
Can I just exclude some of them to suit the JTable model where appropriate?


Remove the TableColumn from the TableColumnModel of the JTable. The data will still be contained in the TableModel, but the column will not be displayed in the view (JTable).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to exclude certain columns from a prefilled object from the db module to a model?