How to reduce javax.faces.ViewState in JSF

半世苍凉 提交于 2019-12-02 17:39:11
Cristian Vat

Have you tried setting the state saving to server? This should only send an id to the client, and keep the full state on the server. Simply add the following to the file web.xml :

 <context-param>
  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  <param-value>server</param-value>
 </context-param>

If you are using MyFaces you can try this setting to compress the viewstate before sending to the client.

<context-param>
    <param-name>org.apache.myfaces.COMPRESS_STATE_IN_CLIENT</param-name>
    <param-value>true</param-value>
</context-param> `

One option is to completely save the view state on client side but you may face some problem such as not being able to Serialize the object. You may want to try using different compression algorithm/utility based on your requirement but since the browser will already use the GZip by default I am not sure how much you can gain.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!