From c6905c976ce9404bed18e3ba006b3c84bba001a5 Mon Sep 17 00:00:00 2001 From: Volodymyr Siedlecki Date: Thu, 22 Feb 2024 15:08:55 -0500 Subject: [PATCH] Revert "Remove deprecated bindings field" This reverts commit d3aed2499c582c461676cece1a9f845fde77fe1b. --- .../jakarta/faces/component/UIComponent.java | 9 ++++- .../faces/component/UIComponentBase.java | 34 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/impl/src/main/java/jakarta/faces/component/UIComponent.java b/impl/src/main/java/jakarta/faces/component/UIComponent.java index 9035df2301..6a42b119da 100644 --- a/impl/src/main/java/jakarta/faces/component/UIComponent.java +++ b/impl/src/main/java/jakarta/faces/component/UIComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to Eclipse Foundation. + * Copyright (c) 2022, 2024 Contributors to Eclipse Foundation. * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -2378,4 +2378,11 @@ private Resource findComponentResourceBundleLocaleMatch(FacesContext context, St return resourceBundle != null ? result : null; } + // The set of ValueExpressions for this component, keyed by property + // name This collection is lazily instantiated + // The set of ValueExpressions for this component, keyed by property + // name This collection is lazily instantiated + @Deprecated + protected Map bindings = null; + } diff --git a/impl/src/main/java/jakarta/faces/component/UIComponentBase.java b/impl/src/main/java/jakarta/faces/component/UIComponentBase.java index 8b660b0634..9b01166d38 100644 --- a/impl/src/main/java/jakarta/faces/component/UIComponentBase.java +++ b/impl/src/main/java/jakarta/faces/component/UIComponentBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to Eclipse Foundation. + * Copyright (c) 2022, 2024 Contributors to Eclipse Foundation. * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -1141,6 +1141,10 @@ public Object saveState(FacesContext context) { Object savedBehaviors = saveBehaviorsState(context); Object savedBindings = null; + if (bindings != null) { + savedBindings = saveBindingsState(context); + } + Object savedHelper = null; if (stateHelper != null) { savedHelper = stateHelper.saveState(context); @@ -1174,6 +1178,10 @@ public Object saveState(FacesContext context) { values[1] = saveSystemEventListeners(context); values[2] = saveBehaviorsState(context); + if (bindings != null) { + values[3] = saveBindingsState(context); + } + if (stateHelper != null) { values[4] = stateHelper.saveState(context); } @@ -1217,6 +1225,10 @@ public void restoreState(FacesContext context, Object state) { behaviors = restoreBehaviorsState(context, values[2]); } + if (values[3] != null) { + bindings = restoreBindingsState(context, values[3]); + } + if (values[4] != null) { getStateHelper().restoreState(context, values[4]); } @@ -1434,6 +1446,26 @@ private static Map restoreBindingsState(FacesContext co } + private Object saveBindingsState(FacesContext context) { + + if (bindings == null) { + return null; + } + + Object values[] = new Object[2]; + values[0] = bindings.keySet().toArray(new String[bindings.size()]); + + Object[] bindingValues = bindings.values().toArray(); + for (int i = 0; i < bindingValues.length; i++) { + bindingValues[i] = saveAttachedState(context, bindingValues[i]); + } + + values[1] = bindingValues; + + return values; + + } + private Object saveSystemEventListeners(FacesContext ctx) { if (listenersByEventClass == null) {