You can use the FacesContext#getRenderResponse()
to confirm if the process (or order) to proceed to the RENDER_RESPONSE
phase has been initiated. This checks whether renderResponse()
method has been called by a component, signalling the runtime to transfer control to the RENDER_RESPONSE
phase. Generally at this point it's unsafe to attempt to do anything with the response stream.
Another route to the RENDER_RESPONSE
phase is the FacesContext#responseComplete()
method. This however, does not directly trigger the response processing. Rather, it's the final flag to indicate to the runtime that RENDER_RESPONSE
has been arrived at.
So, per the spec, FacesContext#getResponseComplete()
is the ultimate check to verify the state of the response
In some circumstances, it is possible that both renderResponse()and responseComplete()might have been called for the request. In this case, the JSF implementation must respect the
responseComplete()call (if it was made) before checking to see if renderResponse()was called.