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 2008/10/19 03:25:22 UTC
svn commit: r705948 -
/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java
Author: slessard
Date: Sat Oct 18 18:25:21 2008
New Revision: 705948
URL: http://svn.apache.org/viewvc?rev=705948&view=rev
Log:
MYFACES-1987 : Implement UIComponent getCurrentCompositeComponent(FacesContext context)
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=705948&r1=705947&r2=705948&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 Sat Oct 18 18:25:21 2008
@@ -38,6 +38,7 @@
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
+import javax.faces.application.Resource;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
@@ -89,11 +90,16 @@
public static UIComponent getCurrentCompositeComponent(FacesContext context)
{
- // TODO: JSF 2.0 #46
- // UIComponent currentComponent = getCurrentComponent(context);
- // Loop through parents to find a composite component
-
- throw new UnsupportedOperationException();
+ // 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;
}
public abstract Map<String, Object> getAttributes();
@@ -438,6 +444,11 @@
return getClientId(ctx);
}
+
+ private boolean _isCompositeComponent()
+ {
+ return getAttributes().get(Resource.COMPONENT_RESOURCE_KEY) != null;
+ }
private static class BundleMap implements Map<String, String>
{