[ https://issues.apache.org/jira/browse/MYFACES-4716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17938315#comment-17938315 ]
Werner Punz commented on MYFACES-4716: -------------------------------------- Same result on 4.0.3 here: Selected values: [2] Selected values: [2, 3] Selected values: [2, 3, 4] Selected values: [2, 3] Selected values: [2] Selected values: [] How does your Backing bean look like? I wonder if something else is the problem here, the multi select performs fine here! > Ajax is not working for empty selection for h:selectManyListbox > --------------------------------------------------------------- > > Key: MYFACES-4716 > URL: https://issues.apache.org/jira/browse/MYFACES-4716 > Project: MyFaces Core > Issue Type: Bug > Affects Versions: 4.0.2 > Reporter: Gordon Freeman > Assignee: Werner Punz > Priority: Major > > I have multiselect on the form: > {code} > <h:selectManyListbox id="someId" value="#{myBackingBean.valueList}"> > <f:selectItems value="${myBackingBean.valueSelectItems}" /> > <f:ajax execute="@this" render="someOtherId" event="valueChange" > listener="#{myBackingBean.valueChanged}"/> > </h:selectManyListbox> > {code} > When I deselect the last option in the multiselect I expect the empty list to > be setted to the backing bean _valueList_ and the _valueChanged_ method to be > called. > But the _valueChanged_ method is not called and a crash occurs at the > validation stage due to NPE. > {code} > org.apache.myfaces.core.api.shared.SelectItemsUtil.matchValue(SelectItemsUtil.java:235) > jakarta.faces.component.UISelectMany.validateValue(UISelectMany.java:332) > jakarta.faces.component.UIInput.validate(UIInput.java:717) > jakarta.faces.component.UIInput.processValidators(UIInput.java:297) > org.apache.myfaces.context.servlet.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:717) > org.apache.myfaces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:226) > jakarta.faces.component.UIComponent.visitTree(UIComponent.java:880) > jakarta.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1120) > jakarta.faces.component.UIComponent.visitTree(UIComponent.java:908) > jakarta.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1120) > jakarta.faces.component.UIComponent.visitTree(UIComponent.java:908) > jakarta.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1120) > jakarta.faces.component.UIComponent.visitTree(UIComponent.java:908) > jakarta.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1120) > jakarta.faces.component.UIComponent.visitTree(UIComponent.java:908) > jakarta.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1120) > jakarta.faces.component.UIForm.visitTree(UIForm.java:343) > jakarta.faces.component.UIComponent.visitTree(UIComponent.java:908) > jakarta.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1120) > org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartialExecute(PartialViewContextImpl.java:407) > org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:388) > jakarta.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1857) > jakarta.faces.component.UIViewRoot._process(UIViewRoot.java:1714) > jakarta.faces.component.UIViewRoot.processValidators(UIViewRoot.java:972) > org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:39) > > org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:172) > org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:125) > jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:223) > {code} > According to the _HtmlRendererUtils.decodeUISelectMany_ method, when posting > an empty multiselect, no parameters for this multiselect should be sent to > the server. > But the parameter is sent - it is an empty string. It is filled in > _XhrRequest.ts_ when calling _this.appendIssuingItem(formData);_ > I think this is a bug (probably introduced in MYFACES-4606) in js and with an > empty multiselect the parameter should not be sent in the POST request. > And the current behavior is as if an option with an empty value was selected > in the multiselect, _submittedValue_ is an array of one element - an empty > string, instead of empty array. -- This message was sent by Atlassian Jira (v8.20.10#820010)