JSF 视图实例之间的区别:新视图、初始视图和回发视图
我对 JSF 视图实例做了一些研究:新视图、初始视图和回发视图。但是,我仍然不太确定这些差异。这有点令人困惑,我还没有找到很好的解释。有人可以解释一下这个吗?
I did some research on JSF view instances: new view, initial view, and postback view. But, I am still not quite sure about the differences. It's kind of confusing and I haven't been able to find a good explanation on that. Can somebody put some light on this one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是 JSF 1.0/1.1 的工作原理。 这篇古老的 IBM 文章对它们进行了详细解释。但是您应该忘记并忽略整篇文章(另请参阅顶部的“编者注”部分,该部分是后来编辑的)。自 JSF 1.2 及更高版本(包括 JSF 2.x)以来,它不再适用。只有“初始视图”和“回发视图”。 “新观点”已不复存在。
初始视图是根据 GET 请求创建的,现有视图根据 POST 请求重用。当 GET 请求导致 POST 的
响应时,(部分)视图将由名为javax.faces.ViewState< 的隐藏输入字段引用/代码>。这个完全相同的视图将被恢复并用于处理表单提交(回发)。
That was how JSF 1.0/1.1 works. They are explained in detail in this ancient IBM article. But you should forget and ignore the whole article (see also "Editor's notes" section on top which was edited in afterwards). It does not apply anymore since JSF 1.2 and newer (including JSF 2.x). There is only "initial view" and "postback view". The "new view" does not exist anymore.
An initial view is been created upon a GET request and an existing view is been reused upon a POST request. When a GET request results in a response with a
<h:form>
for POST, then the (partial) view is referenced by a hidden input field with namejavax.faces.ViewState
. This very same same view will be restored and used to process the form submit (the postback).