Why implement the serializable in the JSF managed bean?
When to use and not to use?
What is the serializable interface for?
Why implement the serializable in the JSF managed bean?
When to use and not to use?
What is the serializable interface for?
In summary, the class that inherits from the Serializable interface that it can be serialized (in practical terms, the instance of the object of the class in question can be converted into bytes and be written to disk, or sent by 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, which in turn is associated with a HttpSession . Everything in a HttpSession needs to be serializable, so that in cases of server crashes, or any other situation where it is necessary to persist the session to disk, to recover it 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 secures the same session across a 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 cases of full EE stack applications, or even using JPA together with JSF, it is advisable to use the Serializable interface. The interface has its uses also with JPA, but the details are outside the scope of the question.