8

Seems like I am having a bunch of JSF related questions these days... here it goes again: why does AJAX call declared with f:ajax post all the fields of the form and not only those declared with execute? This question was already asked in the Sun forums, but as they are now closed I cannot reply there. The thread there is a stub with no real answer to this.

What's the point of submitting all the form fields if I need to use only some of them?

Tuukka Mustonen
  • 4,722
  • 9
  • 49
  • 79

3 Answers3

5

I just checked the JSF ticket that Tuuka had posted way back in Jan 2011. It said that this behavior (submitting all the form fields) is consistent with the JSF spec, and the issue was closed.

The JSF developers have posted a spec change notice that this should be modified in an upcoming spec. This had a date of Jan 31, 2013. https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1098

"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."

"Status: open Priority: major"

Yamaneko
  • 3,433
  • 2
  • 38
  • 57
klevi
  • 66
  • 1
  • 2
2

This seems to be a bug in the jsf.js The getViewState function returns all the parameters (instead of filtering them), which are then sent to the server in the request string.

example: j_idt15=j_idt15&j_idt15%3Avalue1=4444&j_idt15%3Avalue2=555&j_idt15%3Avalue3=6664&javax.faces.ViewState=-6275268178907195611%3A5276476001199934151&javax.faces.source=j_idt15%3Avalue1&javax.faces.partial.event=blur&javax.faces.partial.execute=j_idt15%3Avalue1%20j_idt15%3Avalue1&javax.faces.partial.render=value1out&javax.faces.partial.ajax=true

Here you can see that the even though javax.faces.partial.execute is correctly specified as: j_idt15:value1, the request still contains all the values

Rami Ayoub
  • 96
  • 3
  • So the bug resides in javascript level - that's why it works in the Java level (JSF only setting the bean fields marked with `execute` despite of all fields sent). Note that the bug is not only about filtering the right fields, if two or more different forms are specific by `execute`, only the fields in the wrapping form are still sent. So it's a bit bigger issue. I am going to raise a ticket for this in the Mojarra tracker once it's available again after ongoing infrastrcture migration. – Tuukka Mustonen Nov 30 '10 at 07:49
  • Hmm, seems like I forgot to accept this ages ago. Picking it now! – Tuukka Mustonen Jan 20 '11 at 17:06
1

I am not 100% sure, but this might be a bug in Mojarra. See a similar question about the special @all keyword.

In short: Mojarra doesn't obey the list of forms entered for execute attribute of f:ajax but always submits only the enclosing form. The same probably applies to a more detailed field level as well - Mojarra does not obey the execute attribute when choosing what fields to submit, but simply sends them all. It does obey the execute attribute when processing the data in the server-side, however.

Can anyone test if the behavior differs from this with Apache Myfaces?

Community
  • 1
  • 1
Tuukka Mustonen
  • 4,722
  • 9
  • 49
  • 79