Description
Right now, the implementation of UIComponentBase.getFacesContext() is this:
@Override
protected FacesContext getFacesContext()
I think it is possible to create a variable like this:
private transient FacesContext _facesContext;
and change the current implementation to:
void setCachedFacesContext(FacesContext facesContext)
{ _facesContext = facesContext; } @Override
protected FacesContext getFacesContext()
{
if (_facesContext == null)
else
{ return _facesContext; }}
Then we do this on methods like processXXX, encodeXXX (not on encodeAll), visitTree and invokeOnComponent:
@Override
public void processDecodes(FacesContext context)
{
try
finally
{ popComponentFromEL(context); setCachedFacesContext(null); }In few words, set and release temporally the variable while those operations are executed. This change will reduce the amount of calls to FacesContext.getCurrentInstance() without side effects, because we are caching only on safe places and enclosing everything in a try finally block.
If no objections I'll commit this code soon.