From 4da8a30bbdfd1ca7b8812e7b01801cc74bfaeeea Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 30 Apr 2022 10:26:28 -0400 Subject: [PATCH] Fix #5081: UISelectMany#getSubmittedValue() should not default to empty string --- .../java/javax/faces/component/UIInput.java | 2 +- .../javax/faces/component/UISelectMany.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/impl/src/main/java/javax/faces/component/UIInput.java b/impl/src/main/java/javax/faces/component/UIInput.java index 3a1bfb05e0..dce66833d5 100644 --- a/impl/src/main/java/javax/faces/component/UIInput.java +++ b/impl/src/main/java/javax/faces/component/UIInput.java @@ -1580,7 +1580,7 @@ private void addConversionErrorMessage(FacesContext context, } - private boolean considerEmptyStringNull(FacesContext ctx) { + boolean considerEmptyStringNull(FacesContext ctx) { if (emptyStringIsNull == null) { String val = ctx.getExternalContext().getInitParameter(EMPTY_STRING_AS_NULL_PARAM_NAME); diff --git a/impl/src/main/java/javax/faces/component/UISelectMany.java b/impl/src/main/java/javax/faces/component/UISelectMany.java index e0d37a1e8b..224aebca67 100644 --- a/impl/src/main/java/javax/faces/component/UISelectMany.java +++ b/impl/src/main/java/javax/faces/component/UISelectMany.java @@ -27,6 +27,7 @@ import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.el.ValueBinding; +import javax.faces.render.Renderer; /** @@ -262,6 +263,26 @@ public String getFamily() { } + private transient Object submittedValue = null; + + + @Override + public Object getSubmittedValue() { + if (submittedValue == null && !isValid() && considerEmptyStringNull(FacesContext.getCurrentInstance())) { // JAVASERVERFACES_SPEC_PUBLIC-671 + return new String[0]; // Mojarra#5081 + } else { + return submittedValue; + } + } + + + @Override + public void setSubmittedValue(Object submittedValue) { + + this.submittedValue = submittedValue; + + } + /** *

Return the currently selected values, or null if there * are no currently selected values. This is a typesafe alias for