• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Implementing serializable interface for reference class

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using a class "CustomValidate.java" in my application. As it is one of the ResultClass (Struts), I have implemented the Serializable interface in the "CustomValidate.java". But still it throws java.io.Serialization exception?

I read from the net that all the class referred inside the Serializable class also needs to implement the Serializable interface to make the object Serializable.

My question is; The "CustomValidate.java" referring two (only following two lines) such external class in a method like the following:

Keys.FirstName (accessing a constant value from Keys.java)
Util.format(FirstName) (Calling a method which is in Util.java)

Does this classes "Keys.java" and "Util.java" also needs to implement the Serializable interface? Please suggest.

Thanks in advance.

Ashok
[ February 22, 2006: Message edited by: ashok sashrith ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, neither of these cases should be a problem. You should get a Serialization error only if you have a member variable of a non-serializable type, or a member variable of a type which itself contains a reference to a nonserializable type, and so on. For example, you might have a member of type ArrayList (which is serializable) holding a bunch of Socket objects (which are not.)

Maybe you can show the code for this class?
 
ashok sashrith
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ernest and here is the code for the same.



Hope it helps. Thanks in advance.
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic