In both MyFaces and Mojarra 2.1, there exists a defect where when javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
is set to true
, any fields that are marked as required and pre-populated in the model, when blanked-out and submitted are re-shown with their original non-blanked-out values instead of being left blank.
Scenario is:
- User loads page with a single required field that is populated with existing data from the model
- User clears out the field on the page and submits the form
- Validation fails, as expected, and the user is shown an error message that they must fill in the required field.
The issue is that the field, which should show what the user submitted -- which is that they submitted a blank value for the field -- is instead populated with the original value from the model. The only workaround is to set javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
to false
. Setting to false
delivers the desired behavior that the field remains blanked out when the page is redisplayed with the required field error message.
A defect was logged with Mojarra (http://java.net/jira/browse/JAVASERVERFACES-2375) and MyFaces (https://issues.apache.org/jira/browse/MYFACES-3525) but no progress has been made in 6 weeks.
Note that it appears Mojarra had a similar issue reported over 6 mos ago yet no progress has been made.
Does anyone know of a workaround for this where we can keep javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
set to true instead of false and yet not encounter this required field usability issue?