I have h:form inside p:dialog element which contains some form fields (e.g. name, description..) and one p:outputPanel with deferred="true" and deferredMode="load" and everything seems to work fine in best use-case scenario. Form is backed with viewscoped bean.

Problem occurs when I try to ajax submit the form (via p:commandButton) with some of the required form fields not filled in (or any other scenario where form validation will fail). After ajax response from server (with all form view elements updated including required fields marked as red...), p:outputPanel element inside form tries to load(update) itself but the ajax request sent by that p:outputPanel contains no javax.faces.ViewState. As I understand, this forces backing @ViewScoped bean to recreate, loosing any bean state and making displayed form invalid (e.g. some of the forms field was populated and they are preserved after validation failure, but after problematic 2nd ajax call even them are invalid..)

I found out that ViewState is missing in ajax call by using Fiddler proxy.

My actual scenario is a little bit complicated, but it boils down to the same problem. I use custom Primefaces component which extends p:outputPanel. I was thinking first that my component was bugged, but then i tried with simple p:outputPanel and got the same result.

So, is there a way to fix this somehow? Can I add ViewState manually? (FixViewState from omniFaces is not helping...) Or maybe I am doing something very wrong?

Also, I use Mojarra JSF 2.2.11, Weld 2.2.8, PF 5.2, OmniFaces and Apache Tomcat 8.0

@Named("databean")
@ViewScoped
public class ViewScopedBackingBean implements Serializable{

    private String name;

    public void add(ActionEvent event) {
        System.out.println("Yuhu :)");
    }

    // ...
}
<h:body>
    <h:form>
        <p:inputText value="#{databean.name}" required="true" />
        <p:outputPanel id="deferredPanel" deferred="true" deferredMode="load">
            <h:outputText value="Name: #{databean.name}" />
        </p:outputPanel>
        <p:commandButton id="addBtn" value="Add"
            actionListener="#{databean.add}" update="@form" />
    </h:form>
</h:body>

web.xml

<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<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>Development</param-value>
</context-param>
<resource-env-ref>
    <resource-env-ref-name>BeanManager</resource-env-ref-name>
    <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
<context-param>
    <param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>primefaces.FONT_AWESOME</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bootstrap</param-value>
</context-param>
0

There are 0 answers