volosied commented on code in PR #492:
URL: https://github.com/apache/myfaces/pull/492#discussion_r1084408193
##########
impl/src/main/java/org/apache/myfaces/renderkit/html/util/HtmlRendererUtils.java:
##########
@@ -292,6 +292,12 @@ public static void decodeUISelectOne(FacesContext
facesContext, UIComponent comp
callback);
}
}
+ else
+ {
+ // means input was not submitted. set to empty string so
we can validate required fields
+ // if not set, a null value will skip validation -- see
beginning of UIInput#validate
+
((EditableValueHolder)component).setSubmittedValue(RendererUtils.EMPTY_STRING);
Review Comment:
Not sure if enums are spec allowed due to this isEmpty() definition:
https://jakarta.ee/specifications/faces/4.0/apidocs/jakarta/faces/component/uiinput#isEmpty(java.lang.Object)
```
If the value is null, return true. If the value is a String and it is the
empty string, return true. If the value is an array and the array length is 0,
return true. If the value is a List and the List is empty, return true. If the
value is a Collection and the Collection is empty, return true. If the value is
a Map and the Map is empty, return true. In all other cases, return false.
```
I think we will need to keep it as is (set to empty string when no value
submitted, if kept as null it would cause validation to be skipped --
https://github.com/apache/myfaces/blob/e9fe59f96410f31a7f5c0fbd6838c1a22683a691/api/src/main/java/jakarta/faces/component/UIInput.java#L650
required is true, but shouldAlwaysPerformValidationWhenRequiredTrue is false)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]