It seems like the partial requests don’t use the faces context instances that are created by FacesContextFactory implementations.
Here’s the code in UIViewRoot#processDecodes that indicates the same
if (context.getPartialViewContext().isPartialRequest() &&
!context.getPartialViewContext().isExecuteAll()) {
context.getPartialViewContext().processPartial(PhaseId.APPLY_REQUEST_VALUES);
} else {
super.processDecodes(context);
}
It seems like the PartialViewContext stores the default FacesContextImpl implementation within it and uses it to call lifecycle methods. (Notice that the processPartial method doesn’t take a context object, because it uses it own internally stored one)
Is this a bug or this code in there for a specific reason?
Thanks
FacesContextinstances are unique per thread, and TheFacesServletcreates aThreadLocal<FacesContext>on the beginning of the request while acquiring theFacesContext(which is the contract ofFacesContextFactory#getFacesContext)and removes it on the end of the response associated with the HTTP servlet request (by calling theFacesContext#release).Whenever you do a
FacesContext#getCurrentInstance()in your JSF code, you’ll always get the same instance throughout the entire HTTP servlet request/response processing.About the method
UIViewRoot#processDecodes,I really don’t see any line which probably can indicate that method uses it’s own created instance rather than the passed one. Which line made you think that?It can be seen in the
FacesServlet#servicemethod that it creates theFacesContextfrom TheFacesContextFactory, here is a excerpt from theFacesServlet#servicemethod which shows this –Considering this, I don’t feel
UIViewRoot#processDecodescan have theFacesContextinstance which is not fromFacesContextFactory.Since you’re saying – you have set some additional parameters to the
FacesContextwhich get returned fromFacesContextFactory, that means you have your own custom implementation ofFacesContextFactory, if this is the case then are you sure that your instance is injected in theFacesServletand not mojarra’scom.sun.faces.context.FacesContextFactoryImpl(if you’re using mojarra)?