Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When using Mojarra, you can use the following context param to tell it to always serialize the JSF state:</p> <pre><code>&lt;context-param&gt; &lt;param-name&gt;com.sun.faces.serializeServerState&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/context-param&gt; </code></pre> <p><em>(MyFaces equivalent is <code>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</code>, but this defaults to <code>true</code> already)</em></p> <p>During testing, you'll get <code>NotSerializableException</code> on instances which are not been marked <code>Serializable</code>. Usually, it are the view and session scoped beans and all their properties which needs to be serializable. </p> <p>Note that marking a property <code>transient</code> is not the right solution, it would remain <code>null</code> after deserialization (after restore view) which is just wrong. There are however certain cases where there is no other way (e.g. 3rd party API), in that case you'd better consider one of the following solutions:</p> <ul> <li><p>Put property in a request scoped bean (you can always inject view/session scoped bean in there and delegate all form actions through it).</p></li> <li><p>Lazily load the property. Example: <a href="https://stackoverflow.com/questions/12641017/changing-request-to-view-scope-results-in-java-io-notserializableexception-java/">Changing request to view scope results in java.io.NotSerializableException: javax.faces.model.ListDataModel</a></p></li> <li><p>Wrap the class in a serializable class. Example: <a href="https://stackoverflow.com/questions/2858493/how-to-make-persistent-cookies-with-a-defaulthttpclient-in-android/">How to make persistent Cookies with a DefaultHttpClient in Android?</a></p></li> </ul> <p>As to business services, as long as you're using EJB or CDI, there's no need to mark business classes serializable. They're been injected as serializable proxies anyway.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload