How many state information is saved when client mode

113 views Asked by At

How to define the max number of component trees in client mode? How to prevent calling @PostConstruct method?

I'm developing an application by JavaEE7 with glassfish 4.1. If I remember correctly, when javax.faces.STATE_SAVING_METHOD is client, there is no limit of component tree. But when I opened more than 25 tabs in Chrome and operate the first tab, that tab's managed bean will construct and call @PostConstruct method. I think this behavior seems losing component tree to me.

The following is source code of my application.

test.xhtml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
    template="/template/template.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    >
    <h:panelGrid columns="5" cellpadding="5" >
        <p:commandButton id="returnButton" value="return"
                         action="#{testEditBean.return()}"
                         immediate="true"
                         />
    </h:panelGrid>
</ui:composition>

testBean.java

import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;

@Named(value = "testBean")
@ViewScoped
public class TestBean implements Serializable {

    @PostConstruct
    public void index() {
    }

    public String doReturn() {
        String ret = "/content/tmp/testSearch.xhtml";
        return ret;
    }
}

[postscript 2016/01/28] I understand that a HTTP session stored view scoped beans (max 25) and view state only stored component tree. This is my new question.

Unless we change mojjara 2.x to another JSF implementation, we couldn't open more than 25tabs? "more than 25 tabs" contains this case that "an user open 2 tabs, and 23 transition occur in 2nd tab."

0

There are 0 answers