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

UIData: return static empty data model if value is null #5304

Merged
merged 1 commit into from
Sep 2, 2023
Merged
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
9 changes: 6 additions & 3 deletions impl/src/main/java/javax/faces/component/UIData.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public class UIData extends UIComponentBase

// ------------------------------------------------------ Manifest Constants


/**
* <p>The standard component type for this component.</p>
*/
Expand All @@ -100,6 +99,10 @@ public class UIData extends UIComponentBase
*/
public static final String COMPONENT_FAMILY = "javax.faces.Data";

// --------------------------------------------------------------- Constants

private static final ListDataModel EMPTY_DATA_MODEL = new ListDataModel(Collections.emptyList());

// ------------------------------------------------------------ Constructors


Expand Down Expand Up @@ -671,7 +674,7 @@ public void setVar(String var) {
public boolean isRowStatePreserved()
{
Boolean b = (Boolean) getStateHelper().get(PropertyKeys.rowStatePreserved);
return b == null ? false : b.booleanValue();
return b != null && b;
}

/**
Expand Down Expand Up @@ -1839,7 +1842,7 @@ protected DataModel getDataModel() {
// Synthesize a DataModel around our current value if possible
Object current = getValue();
if (current == null) {
setDataModel(new ListDataModel(Collections.EMPTY_LIST));
setDataModel(EMPTY_DATA_MODEL);
} else if (current instanceof DataModel) {
setDataModel((DataModel) current);
} else if (current instanceof List) {
Expand Down