From 65d7fdba986d48faa68dc2409b8e2516e98e9b08 Mon Sep 17 00:00:00 2001 From: Paolo B Date: Mon, 14 Aug 2023 17:08:11 +0200 Subject: [PATCH] UIData: return static empty data model if value is null Signed-off-by: pizzi80 --- impl/src/main/java/javax/faces/component/UIData.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/impl/src/main/java/javax/faces/component/UIData.java b/impl/src/main/java/javax/faces/component/UIData.java index c0e1157bbb..230812d452 100644 --- a/impl/src/main/java/javax/faces/component/UIData.java +++ b/impl/src/main/java/javax/faces/component/UIData.java @@ -88,7 +88,6 @@ public class UIData extends UIComponentBase // ------------------------------------------------------ Manifest Constants - /** *

The standard component type for this component.

*/ @@ -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 @@ -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; } /** @@ -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) {