0

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;
            }
        }
sunjavax
  • 91
  • 1
  • 6
  • Welcome to Stack Overflow! `controller.firstName` != `bean.firstName` – Timothy Truckle Jan 05 '17 at 22:14
  • That's true but to test a scenario outside of ui:repeat, i added a field 'firstName' in the class associated with 'controller'. So your response will not solve this issue. – sunjavax Jan 06 '17 at 03:45
  • the point is: when `controller.firstName` returns a value it does not mean that `bean.firstName` returns a value too. Did you double check that the bean is correctly filled and the getter is no empty stub? – Timothy Truckle Jan 06 '17 at 07:09
  • Yes i have checked it. As mentioned in the post i have put break points in several places and can see that decode on inputText is called properly and it can get the value from request - along with that UIRepeat is resetting the submitted value back to null - hence during encode in the inputText renderer it gets null value to display in the text box. I guess i am missing some fundamental issue on restore of `ui:repeat` - inputText outside of ui:repeat behaves as i expected. – sunjavax Jan 06 '17 at 14:55
  • Can you update the question with your backing beam? – wtlucy Jan 06 '17 at 19:39
  • @wtlucy - Added the test code for backing beans – sunjavax Jan 06 '17 at 22:40
  • Based on my reading of the following answer, it seems that the behavior here may be expected. Why do you need to use the immediate attribute here? http://stackoverflow.com/a/12961162/3864977 – wtlucy Jan 09 '17 at 16:35
  • @wtlucy-1of2 - Thanks for the pointer, but the issue is why text component submitted value is getting set to null inside ui:repeat and not outside of it. It has to do something with the restore of ui:repeat. I have checked the source code of both Mojarra and MyFaces related to apply request phase and corresponding processDecodes method, i don't see anything in there which can help me to resolve this anomaly. – sunjavax Jan 10 '17 at 19:15
  • @wtlucy-2of2 - Regarding why i am setting immediate=true as i don't want update model phase to occur, so that listener method invocation can occur in apply request phase and from there i can execute renderResponse on FacesContext so that other phases don't get executed. But when render response occurs i still want the values submitted to appear and not get reset to null as ui:repeat is doing it. – sunjavax Jan 10 '17 at 19:15
  • Tagging OmniFaces - may be Balusc happens to look at this - and provide some pointer – sunjavax Jan 10 '17 at 19:16

0 Answers0