volosied commented on code in PR #492: URL: https://github.com/apache/myfaces/pull/492#discussion_r1087077197
########## api/src/main/java/jakarta/faces/component/UISelectOne.java: ########## @@ -90,37 +91,43 @@ public void processValidators(FacesContext context) @Override public VisitResult visit(VisitContext visitContext, UIComponent target) { + // check they they are of the same group if (target instanceof UISelectOne && ((UISelectOne) target).getGroup().equals(group)) { - UISelectOne radio = (UISelectOne) target; - - // if target is an instance of UISelectOne then get all the UISelectItem children - // and verify if the submitted value exists - for (Iterator<UIComponent> iter = radio.getChildren().iterator(); iter.hasNext(); ) - { - UIComponent component = iter.next(); - if (component instanceof UISelectItem) - { - UISelectItem item = (UISelectItem) component; - if (item.getItemValue().equals(submittedValue)) - { - selectItemValueFound = true; - return VisitResult.COMPLETE; - } - } - - } - return VisitResult.REJECT; Review Comment: Additionally, the current code causes a failure with the Spec329 test: ``` Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class ee.jakarta.tck.faces.test.javaee8.uiinput.Spec329Entity (java.lang.String is in module java.base of loader 'bootstrap'; ee.jakarta.tck.faces.test.javaee8.uiinput.Spec329Entity is in unnamed module of loader com.ibm.ws.classloading.internal.AppClassLoader @e7d2dc5) at ee.jakarta.tck.faces.test.javaee8.uiinput.Spec329Entity.equals(Spec329Entity.java:33) at jakarta.faces.component.UISelectOne$1.visit(UISelectOne.java:105) at org.apache.myfaces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:140) at jakarta.faces.component.UIComponent.visitTree(UIComponent.java:873) at jakarta.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1120) at jakarta.faces.component.UIData.visitTree(UIData.java:2234) at jakarta.faces.component.UIForm.visitTree(UIForm.java:343) at jakarta.faces.component.UISelectOne.processValidators(UISelectOne.java:88) ``` The new code works fine for me and if you submit some other value in the form (other than the available options), you'll just get this type of error. ```inDataTableWithEntityList:table:0:radio: Validation Error: Value is not valid``` As far as I can tell, this code is good. -- 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: dev-unsubscr...@myfaces.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org