Skip to content

Commit

Permalink
Revert "Remove deprecated bindings field"
Browse files Browse the repository at this point in the history
This reverts commit d3aed24.
  • Loading branch information
volosied committed Feb 22, 2024
1 parent f9a9dcc commit c6905c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
9 changes: 8 additions & 1 deletion impl/src/main/java/jakarta/faces/component/UIComponent.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<String, ValueExpression> bindings = null;

}
34 changes: 33 additions & 1 deletion impl/src/main/java/jakarta/faces/component/UIComponentBase.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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]);
}
Expand Down Expand Up @@ -1434,6 +1446,26 @@ private static Map<String, ValueExpression> 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) {
Expand Down

0 comments on commit c6905c9

Please sign in to comment.