JSF2 with GAE and ViewScoped ManagedBean

I managed to get a prototype with JSF2 that started working in Googles AppEngine after this tutorial . Now I have weird behavior with ViewScoped ManagedBean:

@ManagedBean @ViewScoped
public class TestBean implements Serializable
{
  private String text;         //getter/setter
  private List<String> texts;    //getter

  @PostConstruct public void init() 
  {
    texts = new ArrayList<String>();
    texts.add("Test");
    text = new String();
  }

  public void save(ActionEvent ae)
  {  
    texts.add(text);
    text = new String();
  }
}

This is my .xhtml page:

<h:body id="body">
  <f:view contentType="text/html">
     <h:form id="frm">
        <p:panel>  
            <h:panelGrid columns="2" id="grid">   
                <p:inputText value="#{testBean.text}"/>  
                <p:commandButton value="Add" update=":frm:op @parent"
                                actionListener="#{testBean.save}" />   
            </h:panelGrid>
        </p:panel>
        <p:outputPanel id="op">
           <p:dataTable var="v" value="#{testBean.texts}">  
              <p:column><h:outputText value="#{v}" /></p:column>
           </p:dataTable>
        </p:outputPanel>
     </h:form>
  </f:view>
</h:body>

This works fine for local deployments (using the Eclipse tools for GAE), but if I use it for GAE, nothing will happen if I click the Add-Button. Additional tests with scope (in GAE) show the following after clicking the Add button:

  • @RequestScoped: Entered text does not disappear, is not added to dataTable
  • @ViewScoped: Entered text does not disappear, is not added to dataTable
  • @SessionScoped: Entered text disappears, dataTable always has two entries: "Test" and the last entered text

I have the same parameter from the tutorial

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

//appengine-web.xml
<sessions-enabled>true</sessions-enabled>

Update 1

@ManagedBean @ViewScoped:

( refreh ) @PostConstruct init(). , , test.jsf , save() . Firebug POST test.jsf :

<?xml version='1.0' encoding='UTF-8'?>
<partial-response><error>
  <error-name>class javax.faces.application.ViewExpiredException</error-name>
  <error-message>
     <![CDATA[viewId:/test.jsf - View /test.jsf could not be restored.]]>
  </error-message>
  </error>
  <extension primefacesCallbackParam="validationFailed">
    {"validationFailed":false}
  </extension>
</partial-response>

2

mojarra-2.0.4, 2.0.6. , : Firefox, ViewExpiredException , 1 List<String>. @PostConstruct , .

myfaces-2.0.7, :

Uncaught exception from servlet
java.lang.NoClassDefFoundError: Could not initialize class
com.google.apphosting.runtime.security.shared.stub.javax.naming.InitialContext

, myfaces , google mojarra (2.0.4) .

+5
1

, , . , , , . :

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

, , JAVASERVERFACES-1886.

+2

All Articles