4 Replies Latest reply on Aug 8, 2011 1:19 PM by phasor

    h:inputText not updating

    phasor
      Hi all,


      I´m having an issue when i try to update an h:inputText control that loads it´s value from conversation context :

      <h:inputText name="oneName" value="#{myName}"/>
             
      The very same page contains a h:commandButton that simply changes the myName conversation variable

      <h:commandButton actionListener="#{dummyMain.setNameConversation}" value="Update Me" />
              
      And the component implementation contains the following code:

              @Out(value="myName",required=false)
              @In(value="myName",required=false)
              private String name;


      public void setNameConversation(ActionEvent event)
      {
                      this.name="Something else";
      }

      After clicking the updateMe commandButton i expected to see the "something else" string in the oneName inputText, but it remains unchanged.
      Shouldn´t seam outject name variable after setNameConversation invocation? What am i´m doing wrong?




      Thanks in advance
      Bruno

        • 1. Re: h:inputText not updating
          arturfriesen

          Is setNameConversation called after you click the Button?
          Do you wrap your code in a h:form tag?

          • 2. Re: h:inputText not updating
            phasor
            Hi,

            setconversation was called. Actually i made a change to the mentioned code including a redirect=true on the page navigation definition and also changing the listener to action instead of actionListener.
            But now i ran into another issue. If i returned null from action method the input wasn´t updated. But if i returned "/mypage.xhtml" everything works as expected and inputText was reset. Navigation Handler shouldn´t treat "return null" as "navigate to the same page" and redirect to page before render, according to redirect=true expression?

            Thanks in advance
            • 3. Re: h:inputText not updating
              kragoth

              Returning null from your action method is a special case in JSF. I don't have time to go into all the details but essentially it will not build a new uiroot and not redirect you. Basically it will just rerender what was on the screen.


              Instead just return and empty string "". (I think this works :S it's been a long time since I used standard JSF navigation).

              • 4. Re: h:inputText not updating
                phasor


                Thank you all in helping me out on this issue.
                That´s resolved.



                Thanks
                Bruno