How can I serialize a JTable?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mariola_Gburzynski
Posted On:   Wednesday, May 16, 2001 10:03 AM

I am trying to serialize the JTable or TableModel.
I need to pass it to the servlet, so I set it as a parameter of my ServletRequest object.
I get the following exception:
"Exception in getResponse javax.swing.ToolTipManager$1 java.io.NotSerializableException: javax.swing.ToolTipManager$1 "
Does anybody know the workaround this problem? Thank you. Mariola

Re: How can I serialize a JTable?

Posted By:   Christopher_Schultz  
Posted On:   Wednesday, May 16, 2001 10:27 AM

Ugh.


Why are you serializing the JTable?
Or the TableModel?
Why not just serialize the data you want to send?


I suppose sending a TableMode isn't horrible.
The problem is, TableModels aren't guarenteed
to be Serializable.


If you're betting on the fact that whatever JTable.getModel()
returns will be Serializable, then I gusss you're okay.


Another problem is that if you want to serialize something complicated like
whatever's inside a TableModel, you have to make sure that
100% of the objects hidden inside that TableModel are
Serializable. If you're careful, and only insert Serializable
objects, you'll be okay.


There's no real good way to get around the exact exception
you're encountering. It looks like you're trying to serialize the
JTable, and it's tripping up on the
ToolTipManager, which is probably not
Serializable.


Try serializing the TableModel directly.


-chris
About | Sitemap | Contact