Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5081: UISelectMany#getSubmittedValue() should not default to empty string #5082

Merged
merged 1 commit into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion impl/src/main/java/javax/faces/component/UIInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions impl/src/main/java/javax/faces/component/UISelectMany.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.el.ValueBinding;
import javax.faces.render.Renderer;


/**
Expand Down Expand Up @@ -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;

}

/**
* <p>Return the currently selected values, or <code>null</code> if there
* are no currently selected values. This is a typesafe alias for
Expand Down