Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF 2.0 RenderResponse and ResponseComplete

Tags:

jsf-2

My understanding of JSF is still shallow.

I am reading the document and as per javadoc of FacesContext

there is the RenderResponse and ResponseComplete that allows you to short-circuit the lifecycle.

I am currently confused.. when do you use the one over the other in real situation?

Thanks

like image 896
Mark Estrada Avatar asked Apr 10 '12 03:04

Mark Estrada


1 Answers

Use FacesContext#renderResponse() if you want to move forward to the render response phase right now. You see this often in combination with value change listener hacks which run in validations phase and should skip the update model values and invoke action phases.

Use FacesContext#responseComplete() to signal JSF that you've already handled the response yourself and that JSF thus doesn't need to render the response. You see this often in combination with backing bean action methods which write a file download to the response. This will ensure that JSF don't append the file download with the content of the rendered HTML which may end up in corrupted download or an illegal state exception.

like image 188
BalusC Avatar answered Oct 14 '22 06:10

BalusC