JSF 2.0 RenderResponse和ResponseComplete [英] JSF 2.0 RenderResponse and ResponseComplete

查看:170
本文介绍了JSF 2.0 RenderResponse和ResponseComplete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对JSF的理解仍然很浅.

我正在阅读文档,并按照解决方案

如果要立即进入渲染响应阶段,请使用FacesContext#renderResponse().您经常会在验证阶段运行值更改侦听器黑客程序,并经常跳过更新模型值并调用操作阶段.

使用FacesContext#responseComplete()通知JSF您已经自己处理了响应,因此JSF不需要呈现响应.您经常会看到这种情况与后备bean动作方法结合使用,后者将文件下载写入响应.这样可以确保JSF不会在文件下载后附加呈现的HTML内容,否则可能会导致下载损坏或非法状态异常.

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

解决方案

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.

这篇关于JSF 2.0 RenderResponse和ResponseComplete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆