JSF 2.2 ui:repeat setting input text component submitted value to null for immediate scenario during processDecodes

607 views Asked by At

Env: WebSphere Liberty - 16_0_0_3 (JEE 7), JSF 2.2, PrimeFaces 6.0, Omnifaces 2.4, JDK 1.7+

I am using a primefaces remote command (by clicking on a link and calling the remote command by its name) to invoke an actionListener with immediate=true and partialSubmit=true. In simplistic world i am processing an output panel that internally has ui:repeat and ui:repeat has p:inputText.

        <p:outputPanel id="_container">
            <ui:repeat var="bean" value="#{controller.beanList}"> 
                <p:inputText value="#{bean.firstName}" />
            </ui:repeat>
        </p:outputPanel>    

<p:remoteCommand name="remoteCommand" actionListener="#{controller.process}" process="_container" update="_container" partialSubmit="true" immediate="true"/>

i am also executing facesContext.renderResponse() as the last statement in the listener.

Issues: Whatever value that gets submitted when ajax request is processed does not redisplays in the input text, it comes as blank. I can see the values submitted in the browser developer tools - on further investigation i found that UIRepeat is setting the submittedValue back to null during processDecodes (in the apply request values phase) through its method named UIRepeat.restoreDescendantComponentStates

But if i test the same scenario without ui:repeat then whatever value is submitted from the browser gets redisplayed i.e.

<p:outputPanel id="_container">             
        <p:inputText value="#{controller.firstName}" />
    </p:outputPanel> 

Not sure why ui:repeat is setting the submitted values as null.

Here is test code for backing beans as requested by @wtlucy

        package test;

        import java.util.ArrayList;
        import java.util.List;

        import javax.annotation.PostConstruct;
        import javax.faces.view.ViewScoped;
        import javax.inject.Named;

        @Named
        @ViewScoped
        public class Controller {

            private String firstName;

            private List<TestBean> beanList;

            @PostConstruct
            public void initialize(){
                this.beanList = new ArrayList<>();      
                for(int i=0 ; i<2; i++){
                    this.beanList.add(new TestBean());
                }
            }

            public String getFirstName() {
                return firstName;
            }

            public void setFirstName(String firstName) {
                this.firstName = firstName;
            }

            public List<TestBean> getBeanList() {
                return beanList;
            }
        }

           package test;

           public class TestBean {

            private String firstName;

            public String getFirstName() {
                return firstName;
            }

            public void setFirstName(String firstName) {
                this.firstName = firstName;
            }
        }
0

There are 0 answers