So, I did more investigation about how Mojarra saves state in the server. I went through Mojarra source code, wrote a session listener and a Servlet that prints out the contents of user session. This is what I found:
Mojarra adds a Map in the session with the name "com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap". For every unique XHTML page requested from a tab, an entry is added to that Map. This entry is also a Map. View state is saved within this second map. From what I can see, a separate state is being saved for the initial GET request for the page and then for every postback. For example, if a user first views a page and then submits a form 3 times, then 4 separate states are saved for the same page. I believe, Mojarra has no choice but to save every postback to support the browser's back button.
Conceptually, the contents of the top level Map (the one saved in the session with the name "com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap") goes as follows:
/index.xhtml:Tab#1. This is a map and contains:
- View state for initial GET
- View state for postback #1
- View state for postback #2
/index.xhtml:Tab#2. This is a map and contains:
- View state for initial GET
- View state for postback #1
- View state for postback #2
/another.xhtml:Tab#1. This is a map and contains:
- View state for initial GET
- View state for postback #1
- View state for postback #2
The implications of this for a busy site is frightening.