Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization in JTable

 
sirisha pu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I want to send the Object of JTable from servlet/ejb to an applet.Since JTable is serialized I should be able to do this.
But ToolTipManager which is not serialized is referenced somewhere in JTable or the TableModel ,so I get a notserialized exception.
If I try to serialize an object which has references of not serialized objects may be inner classes which I am not creating ,then how do I use them?
regards,
suchitra
 
Amit Zzz Kulkarni
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if you will get this post. But here goes.
There is no need to serialize JTable ,all data in the JTabel actually resides in the TableModel.Send across the raw data itself as it may reduce network traffic and help load up your Applet speedily.In applet populate teh TableModel with this data and then construct the JTable.
This Swing Component alongwith JTree is modeled in MVC (Model-View-Contoller) pattern. The Jtable is just a GUI display ,formally called as View ,whereas the TableModel either AbstractTableModel or DefaultTableModel is the Model.The controller is generally the user ;Either via a keyboard ,mouse or another component.
Another bit of advise always try to send across whole objects which are created by you ,whose composition you can control rather than tearing out your hair and trying to make somebody else's object hierarchy work for you.
I wrote a small piece of code (kept in a static method in a Utilities class which uses Reflection) which checks that each instance variable which is not a primitive is implementing serializable. Also in such a class all parameters passed thru methods should be checked at Compile-time itself. Shift the burden as much as possibel to the Compiler.
Feel free to ask me any question,mail me as I am not sure how this site works.
Cheers
Amit
Originally posted by suchitra:
hello,
I want to send the Object of JTable from servlet/ejb to an applet.Since JTable is serialized I should be able to do this.
But ToolTipManager which is not serialized is referenced somewhere in JTable or the TableModel ,so I get a notserialized exception.
If I try to serialize an object which has references of not serialized objects may be inner classes which I am not creating ,then how do I use them?
regards,
suchitra
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic