MyFaces doesn't add javax.faces.ViewState back to ajax update stateless view

I am having some problems triggering multiple repetitions of the same ajax request that updates its closing form with stateless JSF (MyFaces 2.2.8 + CDI OpenWebBeans 1.2.7 running on Tomcat 7).

Here is an SSCCE that will portray the problem better than words. Consider a simple form with both inputText and outputText associated with a bean parameter. Submitting the form simply displays the value next to the inputText.

test.xhtml

<!DOCTYPE html>
<html lang="fr" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html">
<f:view transient="true">
    <h:head>
        <title>Test</title>
    </h:head>
    <h:body>
        <h:form>
            <h:inputText value="#{testBean.txt}" />
            <h:outputText value="#{testBean.txt}" />
            <h:commandButton value="Submit">
                <f:ajax execute="@form" render="@form" />
            </h:commandButton>
        </h:form>
    </h:body>
</f:view>
</html>

      

TestBean.java

@Named
@RequestScoped
public class TestBean {
    private String txt;

    public String getTxt() {
        return txt;
    }

    public void setTxt(String txt) {
        this.txt = txt;
    }
}

      

It couldn't be easier! When sending the value the first time, it works as expected and the output is printed. But when it dispatches at a different time (no matter what the value is), the inputText and outputText fields are freed (and the setter is not called).

What actually happens is that what <input type="hidden" autocomplete="off" value="stateless" id="j_id__v_0:javax.faces.ViewState:1" name="javax.faces.ViewState">

is originally added to the form does not fall back to partial rendering. And when it is manually added to the DOM, the ajax request works again.

Is this behavior expected or is it a bug? Is there a workaround?

Thank!

- Zim

+3


source to share


1 answer


Reproduced. This is indeed a MyFaces bug. It works on Moharre (tested since 2.2.11).



There is nothing you can do other than an error message to MyFaces users. So I did: issue 3992 .

+3


source







All Articles