You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sl...@apache.org on 2009/01/15 01:27:22 UTC
svn commit: r734580 -
/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java
Author: slessard
Date: Wed Jan 14 16:27:22 2009
New Revision: 734580
URL: http://svn.apache.org/viewvc?rev=734580&view=rev
Log:
Tweak for getCurrentComposite component to ensure that UIComponent.CURRENT_COMPOSITE_COMPONENT is always in sync
Modified:
myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java
Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java?rev=734580&r1=734579&r2=734580&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java Wed Jan 14 16:27:22 2009
@@ -108,16 +108,7 @@
public static UIComponent getCurrentCompositeComponent(FacesContext context)
{
- // Return the closest ancestor component, relative to the component returned from
- // getCurrentComponent(javax.faces.context.FacesContext), that is a composite component,
- // or null if no such component exists.
- UIComponent currentComponent = getCurrentComponent(context);
- while (currentComponent != null && !currentComponent._isCompositeComponent())
- {
- currentComponent = currentComponent.getParent();
- }
-
- return currentComponent;
+ return (UIComponent)context.getAttributes().get(UIComponent.CURRENT_COMPOSITE_COMPONENT);
}
public abstract Map<String, Object> getAttributes();
@@ -519,8 +510,33 @@
// Pop the current UIComponent from the FacesContext attributes map so that the previous
// UIComponent, if any, becomes the current component.
- Deque<UIComponent> componentStack = (Deque<UIComponent>) contextAttributes.get(UIComponent._COMPONENT_STACK);
- contextAttributes.put(UIComponent.CURRENT_COMPONENT, componentStack.pop());
+ Deque<UIComponent> componentStack = (Deque<UIComponent>) contextAttributes.get(UIComponent._COMPONENT_STACK);
+
+ UIComponent newCurrent = componentStack.pop();
+ UIComponent oldCurrent = (UIComponent)contextAttributes.put(UIComponent.CURRENT_COMPONENT, newCurrent);
+
+ if (oldCurrent != null && oldCurrent._isCompositeComponent())
+ {
+ // Recalculate the current composite component
+ if (newCurrent != null)
+ {
+ if (newCurrent._isCompositeComponent())
+ {
+ contextAttributes.put(UIComponent.CURRENT_COMPOSITE_COMPONENT, newCurrent);
+ }
+ else
+ {
+ for (UIComponent component : componentStack)
+ {
+ if (component._isCompositeComponent())
+ {
+ contextAttributes.put(UIComponent.CURRENT_COMPOSITE_COMPONENT, component);
+ break;
+ }
+ }
+ }
+ }
+ }
}
@SuppressWarnings("unchecked")
@@ -546,6 +562,10 @@
// popComponentFromEL(javax.faces.context.FacesContext).
contextAttributes.put(UIComponent.CURRENT_COMPONENT, component);
+ if (component._isCompositeComponent())
+ {
+ contextAttributes.put(UIComponent.CURRENT_COMPOSITE_COMPONENT, component);
+ }
}
/**