Description
Originally reported in Faces project: jakartaee/faces#1912
As per latest HTML spec the autocomplete="off" is not anymore valid on hidden fields (e.g. view state, client window state).
It was originally introduced to work around Firefox specific behavior which was not observable on other browsers: #1133
Reproducer:
- Open Faces page with Ajax form (and inspect jakarta.faces.ViewState hidden input field and remember its value).
- Perform Ajax submit.
- Hard-Refresh page and inspect jakarta.faces.ViewState hidden input field. It should have a new value, not the one from the initially opened page.
This happened only in Firefox as per https://bugzilla.mozilla.org/show_bug.cgi?id=520561 and work around was to add autocomplete="off"
to the hidden field.
Fast forward ~15 years, the specific attribute value of off
is considered invalid as per Nu HTML validator https://validator.w3.org/nu/ as per recent changes in HTML spec https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
We can turn off this work around via following context param:
<context-param>
<param-name>com.sun.faces.autoCompleteOffOnViewState</param-name>
<param-value>false</param-value>
</context-param>
The original problem is also not anymore reproducible in current Firefox versions (tested 124.0.2) so I think it's OK to make this config the default as per Mojarra 4.1. I.e. don't anymore render autocomplete="off"
unless explicitly instructed as follows:
<context-param>
<param-name>com.sun.faces.autoCompleteOffOnViewState</param-name>
<param-value>true</param-value>
</context-param>