Implement serializable in JSF

Asked

Viewed 822 times

4

Why to implement serializable in the JSF bean Managed?

When to use and not to use?

What is the serializable interface for?

  • I have already asked a similar question and it was well answered here <http://answall.com/q/35618/15862>

1 answer

5


In short, the class you inherit from the interface Serializable means that it can be serialized (in practical terms, the institution of the object of the class in question can be transformed into bytes and be written to disk, or sent over the network, or passed by value, etc.). The interface itself is a Marker Interface which does not define any method. It basically serves as a "flag".

Why Beans implement Serializable in JSF ?

A view or bean that has a session scope, usually has Beans associated with it/it which in turn is associated with a Httpsession. Everything in an Httpsession needs to be serialized, so that in case of server crash, or any other situation where it is necessary to continue the disk session, for recovery of the same when restarting the server, this guarantees some preservation benefits. Or in more complex cluster cases, sessions need to be stored in a datagrid and/or cache or any other structure that ensures the same session across the node.

Serializable is required in JSF ?

If your application does not have any of the features mentioned above, I see no other reason to use Serializable.

Serializable in Java EE environment ?

In case of "full EE stack" applications, or even if you use JPA together with JSF, it is advisable to use the Serializable interface. The interface also has its uses with JPA, but the details are outside the scope of the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.