Skip to content

Commit

Permalink
Remove UIComponent#CURRENT_(COMPOSITE_)COMPONENT from spec
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Apr 19, 2021
1 parent 7fcf3ae commit 9d5c760
Showing 1 changed file with 2 additions and 100 deletions.
102 changes: 2 additions & 100 deletions impl/src/main/java/jakarta/faces/component/UIComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,6 @@ public abstract class UIComponent implements PartialStateHolder, TransientStateH

private static Logger LOGGER = Logger.getLogger("jakarta.faces.component", "jakarta.faces.LogStrings");

/**
* <p class="changed_added_2_1">
* The <code>ServletContext</code> init parameter consulted by the <code>UIComponent</code> to tell whether or not the
* {@link #CURRENT_COMPONENT} and {@link #CURRENT_COMPOSITE_COMPONENT} attribute keys should be honored as specified.
* </p>
*
* <p>
* If this parameter is not specified, or is set to false, the contract specified by the {@link #CURRENT_COMPONENT} and
* {@link #CURRENT_COMPOSITE_COMPONENT} method is not honored. If this parameter is set to true, the contract is
* honored.
* </p>
*/
public static final String HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME = "jakarta.faces.HONOR_CURRENT_COMPONENT_ATTRIBUTES";

/**
* <p class="changed_added_2_0">
* The value of this constant is used as the key in the component attribute map, the value for which is a
Expand Down Expand Up @@ -213,8 +199,6 @@ enum PropertyKeys {
private boolean isInView;
private Map<String, String> resourceBundleMap;

private transient Boolean isSetCurrentComponent;

// It is safe to cache this because components never go from being
// composite to non-composite.
private transient Boolean isCompositeComponent;
Expand Down Expand Up @@ -1463,31 +1447,10 @@ private static ArrayDeque<UIComponent> _getComponentELStack(String keyName, Map<
return (ArrayDeque<UIComponent>) contextAttributes.computeIfAbsent(keyName, e -> new ArrayDeque<>());
}

// bugdb 18090503

/*
* Respecting the fact that someone may have decorated FacesContextFactory and thus skipped our saving of this init
* param, look for the init param and return its value. The return is saved in a transient ivar to provide performance
* while not perturbing state saving.
*/

private boolean isSetCurrentComponent(FacesContext context) {
if (isSetCurrentComponent != null) {
return isSetCurrentComponent;
}

Boolean honorComponentAttribute = (Boolean) context.getAttributes().get(HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME);
if (honorComponentAttribute != null) {
return honorComponentAttribute;
}

return Boolean.valueOf(context.getExternalContext().getInitParameter(HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME));
}

/**
* <p class="changed_added_2_0">
* Push the current <code>UIComponent</code> <code>this</code> to the {@link FacesContext} attribute map using the key
* {@link #CURRENT_COMPONENT} saving the previous <code>UIComponent</code> associated with {@link #CURRENT_COMPONENT}
* Push the current <code>UIComponent</code> <code>this</code> to the {@link FacesContext} attribute map
* saving the previous <code>UIComponent</code>
* for a subsequent call to {@link #popComponentFromEL}.
* </p>
*
Expand Down Expand Up @@ -1528,21 +1491,10 @@ public void pushComponentToEL(FacesContext context, UIComponent component) {
componentELStack.push(component);
component._isPushedAsCurrentRefCount++;

// We only do this because of the spec
boolean setCurrentComponent = isSetCurrentComponent(context);
if (setCurrentComponent) {
contextAttributes.put(CURRENT_COMPONENT, component);
}

// If the pushed component is a composite component, we need to update that
// stack as well
if (UIComponent.isCompositeComponent(component)) {
_getComponentELStack(_CURRENT_COMPOSITE_COMPONENT_STACK_KEY, contextAttributes).push(component);

// We only do this because of the spec
if (setCurrentComponent) {
contextAttributes.put(CURRENT_COMPOSITE_COMPONENT, component);
}
}
}

Expand Down Expand Up @@ -1594,27 +1546,13 @@ public void popComponentFromEL(FacesContext context) {
componentELStack.pop();
_isPushedAsCurrentRefCount--;

boolean setCurrentComponent = isSetCurrentComponent(context);

// Update the current component with the new top of stack. We only do this because
// of the spec
if (setCurrentComponent) {
contextAttributes.put(CURRENT_COMPONENT, componentELStack.peek());
}

// If we're a composite component, we also have to pop ourselves off of the
// composite stack
if (UIComponent.isCompositeComponent(this)) {
ArrayDeque<UIComponent> compositeELStack = _getComponentELStack(_CURRENT_COMPOSITE_COMPONENT_STACK_KEY, contextAttributes);
if (!compositeELStack.isEmpty()) {
compositeELStack.pop();
}

// Update the current composite component with the new top of stack.
// We only do this because of the spec
if (setCurrentComponent) {
contextAttributes.put(CURRENT_COMPOSITE_COMPONENT, compositeELStack.peek());
}
}
}

Expand Down Expand Up @@ -2439,42 +2377,6 @@ private Resource findComponentResourceBundleLocaleMatch(FacesContext context, St
return resourceBundle != null ? result : null;
}

/**
* <p class="changed_added_2_0">
* <span class="changed_deleted_2_2">The</span> key to which the
* <code>UIComponent</code> currently being processed will be associated with within
* the {@link FacesContext} attributes map. <span class="changed_deleted_2_2">The use
* of this constant is deprecated. Please see
* {@link #HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME} to enable its use.</span>
* </p>
*
* @see jakarta.faces.context.FacesContext#getAttributes()
*
* @since 2.0
*
* @deprecated
*/
@Deprecated
public static final String CURRENT_COMPONENT = "javax.faces.component.CURRENT_COMPONENT";

/**
* <p class="changed_added_2_0">
* <span class="changed_deleted_2_2">The</span> key to which the <em>composite</em>
* <code>UIComponent</code> currently being processed will be associated with within
* the {@link FacesContext} attributes map. <span class="changed_deleted_2_2">The use
* of this constant is deprecated. Please see
* {@link #HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME} to enable its use.</span>
* </p>
*
* @see jakarta.faces.context.FacesContext#getAttributes()
*
* @since 2.0
*
* @deprecated
*/
@Deprecated
public static final String CURRENT_COMPOSITE_COMPONENT = "javax.faces.component.CURRENT_COMPOSITE_COMPONENT";

// 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
Expand Down

0 comments on commit 9d5c760

Please sign in to comment.