UIComponent defines the following type-safe methods for retrieving the "current"
component and composite component:
public static UIComponent getCurrentComponent(FacesContext context);
public static UIComponent getCurrentCompositeComponent(FacesContext context)
In addition, UIComponent also defines two related constants:
public static final String CURRENT_COMPONENT =
public static final String CURRENT_COMPOSITE_COMPONENT =
And specifies that these constants may be used to retrieve the current
component/composite component from the FacesContext attribute map.
These constants assume that a particular implementation is used for
pushing/popping the current component to EL - ie. one that happens to store the
current component/composite component on the FacesContext attribute map.
However, this is a bad assumption for the specification to make, since a more
obvious implementation choice would be to managed the current component info in
The spec should be changed to either:
- Remove these constants. Or...
- Remove the requirement that implementations must publish the current
component/composite component via these constants.
To allow for more reasonable implementations.
Other reasons for de-supporting these constants include:
1. They provide no advantage over the type safe methods that provide access to
the same information.
2. They expose an implementation detail which could lead to dangerous code - ie.
no code other than pushComponentToEl/popComponentToEL should be able mess with
3. The requirement that the FacesContext attributes must be set adds overhead to
implementations which choose to use a stack for managing the current
Note that Mojarra should be switching over to a stack-based implementation soon
and as such #3 will soon mean unnecessary overhead for both Mojarra and MyFaces.
(MyFaces already uses the stack approach and must take extra steps to publish
the current component/composite component values in order to comply with the spec.)