That's the counterpart of pushComponentToEL()
whose Javadoc explains this more elaborately.
pushComponentToEL
public final void pushComponentToEL(FacesContext context, UIComponent component)
Push the current UIComponent this to the FacesContext
attribute map using the key CURRENT_COMPONENT
saving the previous UIComponent
associated with CURRENT_COMPONENT
for a subsequent call to popComponentFromEL(javax.faces.context.FacesContext)
.
This method and popComponentFromEL()
form the basis for the contract that enables the EL Expression "#{component}
" to resolve to the "current" component that is being processed in the lifecycle. The requirements for when pushComponentToEL()
and popComponentFromEL()
must be called are specified as needed in the javadoc for this class.
After pushComponentToEL()
returns, a call to getCurrentComponent(javax.faces.context.FacesContext)
must return this UIComponent
instance until popComponentFromEL()
is called, after which point the previous UIComponent
instance will be returned from getCurrentComponent()
Basically, this approach
public void encodeXxx(FacesContext context) {
try {
pushComponentToEL(context, this);
// ...
}
finally {
popComponentFromEL(context);
}
}
allows you during the // ...
process to grab this
component using #{component}
in EL, or UIComponent#getCurrentComponent()
in a managed bean.
One of well known examples is this construct:
<h:inputText ... styleClass="#{component.valid ? 'valid' : 'error'}" />
where #{component.valid}
basically refers UIInput#isValid()
.