I tried to create a simple web app using ICEfaces and encountered a problem.
Here is the web page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>test</title>
</h:head>
<h:body>
<h:form>
<h:commandButton value="Action" action="#{test1.action}" />
</h:form>
</h:body>
</html>
Here is the backing bean:
@ManagedBean(name = "test1")
@SessionScoped
public class Test1 {
public Test1() {
}
public void action() {
System.out.println("action invoked");
}
}
And here is web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>regconf</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
The problem is that the size of the ViewState is large (checked with Firebug) and it grows each time I click "Action" button. After first request it is 32 KB, after second 61 KB, then 94 KB, 128 KB etc. (seems to me like it always saves the state of the previous request).
The behaviour changes when I set the value of javax.faces.STATE_SAVING_METHOD
param to server
- in this case all works fine and the ViewState remains small after each request (checked it on the server side using StateManager).
I'm using Mojarra 2.1.12 (also tried MyFaces - same result), ICEfaces 3.1.0 and Tomcat 7.0.29.
Thanks in advance.
ICEfaces requires server side state saving, so you should set the following:
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>