[ https://issues.apache.org/jira/browse/MYFACES-1467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464106 ]
David Chandler commented on MYFACES-1467: ----------------------------------------- Cristi, Good catch. Just to clarify, you're saying what's broken is that you can no longer use required="true" and disabled="true" together, correct? I'm actually surprised this ever worked, as these two attributes would seem in conflict with each other. Conceptually, if an input component is disabled, validation can be skipped, so the conditions could be added; however, the spec does not exempt validation from occurring in the case of disabled or readonly, whereas it explicitly states that required="true" with a null value should result in an error. Therefore, a strict reading of the spec would seem to indicate that required="true" and disabled="true" should in fact result in a validation error because required="true" implicitly takes precedence. Having said that, I'm OK with adding conditions to skip validation for disabled or readonly components even when required="true", as this was the de facto behavior before this fix. I understand now how a submitted value of null is "special." Rather than put in explicit checks to call validation only when a field is editable (not disabled or readonly), the current code relies on the fact that the submitted value is null in these cases, and therefore validation is skipped. Whether this was by design or by accident, I wonder. Interestingly, UIInput.processValidators() method skips validation if the component is not rendered. Perhaps we should add checks for disabled and readonly in the same method, as validate() needn't even be called if these attributes are true. I guess it all depends on how strictly we interpret the spec regarding the required attribute. As for where we put the conditions, that depends on whether it ever possible for a disabled or readonly component to have a non-null submitted value. Does anyone know? /dmc > Validation doesn't run for required fields if submitted value is null > --------------------------------------------------------------------- > > Key: MYFACES-1467 > URL: https://issues.apache.org/jira/browse/MYFACES-1467 > Project: MyFaces Core > Issue Type: Bug > Components: General > Affects Versions: 1.1.5-SNAPSHOT, 1.2.0-SNAPSHOT > Reporter: David Chandler > Assigned To: Matthias Weßendorf > Fix For: 1.1.5-SNAPSHOT > > Attachments: patch.txt > > > A component with a required value will not fail validation as expected if the > submitted value is null. This issue is not seen normally because browsers > send the value for an empty text field as an empty string. That is, the POST > data for an empty field1 will contain the field name but no value, like > field1=&field2=something. However, if you use a man-in-the-middle proxy such > as Paros to remove "fieldname=" from the POST data, the submitted value will > be null. UIInput.validate() skips validation for null submitted values, but > since requiredness is also part of validation, the requiredness check gets > skipped, too. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira