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

Revert "Remove deprecated bindings field" #5406

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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