2 Replies Latest reply on Oct 7, 2010 7:29 PM by 801328

    f:ajax tag sends all inputs in the page every time?

    801328
      Hi, I'm learning JSF 2 and trying to use the f:ajax tag. I have a simple form with 3 inputs, only for purposes of testing ajax tag
      <h:form>
         i1<h:inputText id="i1" value="#{myBean.i1}"/>
         i2<h:inputText id="i2" value="#{myBean.i2}"/>
         i3<h:inputText id="i3" value="#{myBean.i3}"/>
         <h:commandButton action="#{myBean.process}" value="go">
            <f:ajax execute="i2" render="o1"/>
         </h:commandButton>
         <h:outputText id="o1" value="#{myBean.o1}"/>
      </h:form>
      When I hit the go button I get the expected results, but in my process method I print every param submitted in the request just for the sake of better understanding the inner workings of JSF. I was surprised to see that all the page inputs where submitted, despite the execute attribute of the ajax tag saying to execute only the id i2. Only the setI2 method is called, though.

      Is this the normal behaviour of ajax in JSF 2, to submit every input in the page for every ajax request? The execute attribute is used to say what will be setted in the bean?
        • 1. Re: f:ajax tag sends all inputs in the page every time?
          800254
          Generally, when you use ajax you don't need the <h:commandButton> anymore. The commandButton still does what it does even when you add an ajax tag to it.

          Try adding an ajax tag to your <h:inputText> elements with the valueChange event attribute, and render="o1" like you have it. You should see the outputText update the way you expect.
          1 person found this helpful
          • 2. Re: f:ajax tag sends all inputs in the page every time?
            801328
            I understand what you're saying, but in the specific cases where a commandButton have a f:ajax, and you specify the execute attribute, why it sends every input to the server? I have read the specification but failed to find any mention of this. It would be good if we could restrict what is sent to the server, but I don't know if that is possible in JSF