javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1908

f:ajax exeucte always sends all the fields of the wrapping form

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Works as designed
    • Affects Version/s: 2.0.3-b03
    • Fix Version/s: None
    • Component/s: ajax
    • Labels:
      None
    • Environment:

      Windows XP, Apache Jetty 6.1.24

    • Status Whiteboard:
      Hide

      size_large importance_medium

      Show
      size_large importance_medium
    • Tags:

      Description

      f:ajax doesn't obey the 'execute' attribute but always sends all the fields in a form. Mojarra does, however, only process the listed fields as supposed. However, excess fields shouldn't be sent because it increases request size.

      Recplicate with:

      <h:form id="form1">
      <h:commandButton>
      <h:inputText id="field1" />
      <h:inputText id="field1x" />
      <f:ajax execute="field1" />
      </h:commandButton>
      </h:form>

      On button click, both fields are sent (but only field1 would be processed).

      See for further info: http://stackoverflow.com/questions/3889894/jsf-2-0-why-does-fajax-send-all-the-form-fields-and-not-only-those-marked-with

        Activity

        Hide
        tuukkamustonen added a comment -

        A correction: JSF does also update models for all the fields. An unwanted behavior!

        Tested with Mojarra 2.0.2 and 2.0.4-b07

        Declaring specific forms like exeucte="form1 form2" has no effect either (if there are multiple forms on the page). Seems like whole execute-attribute is ignored and only the enclosing form is always sent and processed?

        Also seems like there's more wrong with f:ajax execute, see: http://stackoverflow.com/questions/2999101/jsf-2-0-with-fajax-execute-all#3906345

        Another bug about similar thing: JAVASERVERFACES-1719

        Show
        tuukkamustonen added a comment - A correction: JSF does also update models for all the fields. An unwanted behavior! Tested with Mojarra 2.0.2 and 2.0.4-b07 Declaring specific forms like exeucte="form1 form2" has no effect either (if there are multiple forms on the page). Seems like whole execute-attribute is ignored and only the enclosing form is always sent and processed? Also seems like there's more wrong with f:ajax execute, see: http://stackoverflow.com/questions/2999101/jsf-2-0-with-fajax-execute-all#3906345 Another bug about similar thing: JAVASERVERFACES-1719
        Hide
        Ed Burns added a comment -

        Not a showstopper for 2.1.0

        Show
        Ed Burns added a comment - Not a showstopper for 2.1.0
        Hide
        tuukkamustonen added a comment -

        There is a copy-paste error in my original report, correct faceclet is of course:

        <h:form id="form1">
        <h:inputText id="field1" value="#

        {bean.someField}

        " />
        <h:inputText id="field1x" value="#

        {bean.someField2}

        " />
        <h:commandButton>
        <f:ajax execute="field1" />
        </h:commandButton>
        </h:form>

        Also correction: Mojarra does not update the fields not in execute (but does send them) so yes, this isn't as critical as I initially thought. It just requires more bandwith and might confuse developer who is checking what fields get "processed" (by Firebug, for example).

        Show
        tuukkamustonen added a comment - There is a copy-paste error in my original report, correct faceclet is of course: <h:form id="form1"> <h:inputText id="field1" value="# {bean.someField} " /> <h:inputText id="field1x" value="# {bean.someField2} " /> <h:commandButton> <f:ajax execute="field1" /> </h:commandButton> </h:form> Also correction: Mojarra does not update the fields not in execute (but does send them) so yes, this isn't as critical as I initially thought. It just requires more bandwith and might confuse developer who is checking what fields get "processed" (by Firebug, for example).
        Hide
        tuukkamustonen added a comment -

        Mojarra ignoring multiple form targets is a real blocker.

        Show
        tuukkamustonen added a comment - Mojarra ignoring multiple form targets is a real blocker.
        Hide
        frederickkaempfer added a comment - - edited

        At least this behavior is according to the spec. See section 15.1
        "Collecting and Encoding View State":

        Encode the name and value for each input element of FORM_ELEMENT. Only select elements that have at least one of their options selected must be included. only checkbox elements that are checked must be included.

        The jsf.getViewState(FORM_ELEMENT) function is supposed to be called by every Ajax request.

        However, sending in all form elements on every request generates much unneeded overhead in certain cases, so it makes sense to change the spec in that regard. This is an important feature especially for use cases, where you have really large forms, but you want to do smalls thinks like field validation:

        <h:inputText id="field1" value="#

        {...}

        "> <f:ajax exectue="@this" render="errorMessage" event="change"/> ... </h:inputText>

        Here we only want to validate one field, but the whole form gets submitted on every change event.

        Show
        frederickkaempfer added a comment - - edited At least this behavior is according to the spec. See section 15.1 "Collecting and Encoding View State": Encode the name and value for each input element of FORM_ELEMENT. Only select elements that have at least one of their options selected must be included. only checkbox elements that are checked must be included. The jsf.getViewState(FORM_ELEMENT) function is supposed to be called by every Ajax request. However, sending in all form elements on every request generates much unneeded overhead in certain cases, so it makes sense to change the spec in that regard. This is an important feature especially for use cases, where you have really large forms, but you want to do smalls thinks like field validation: <h:inputText id="field1" value="# {...} "> <f:ajax exectue="@this" render="errorMessage" event="change"/> ... </h:inputText> Here we only want to validate one field, but the whole form gets submitted on every change event.
        Hide
        rogerk added a comment -

        Yes. This would require a spec change. I've filed: http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1098

        The current implementation works in line with the spec.

        Show
        rogerk added a comment - Yes. This would require a spec change. I've filed: http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1098 The current implementation works in line with the spec.
        Hide
        rogerk added a comment -

        The implementation is also in line with the html spec:
        http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2

        Show
        rogerk added a comment - The implementation is also in line with the html spec: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2

          People

          • Assignee:
            rogerk
            Reporter:
            tuukkamustonen
          • Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: