pageFlowScope、backingBeanScope、viewScope、applicationScope、sessionScope、requestScope

applicationScope: The object is available for the duration of the application.
sessionScope: The object is available for the duration of the session.
requestScope: The object is available for the duration between HTTP requests until a response is sent back to the client.

In addition to the standard JSF scopes, ADF Faces provides the following scopes:

pageFlowScope: The object is available as long as the user continues navigating from one page to another. If the user opens a new browser window and begins
navigating, that series of windows will have their own pageFlowScope scope.
backingBeanScope: This is used for managed beans for page fragments and declarative components only. The object is available for the duration between HTTP requests until a response is sent back to the client. This is needed because there may be more than one page fragment or declarative component on a page,and to avoid collisions between values, any values must be kept in separate scope instances. Therefore, any managed bean for a page fragment or declarative component must use backingBeanScope scope.
viewScope: The object is available until the ID for the current view changes. Use viewScope scope to hold values for a given page. While requestScope scope
can be used to store a value needed from one page to the next, anything stored in viewScope scope will be lost once the view ID changes.
 

        在以往的应用开发过程中,后端的业务组件(Action/Service/Dao),可以被设置为几种作用域:request、session、application。我们不可能把与每次请求关系很强的一些信息(例如某个列表页面要列出来的数据集合)简单的放到session里面去,这就导致了每次请求之间的大部分数据是不可能共享的。使用JSF,我们实现了一种叫做view的作用域,在不同的请求之间共享信息。


        新版的spring中提出了一个conversation作用于,也是介于request和session之间的一个作用于,和seam中的conversation应该差不多。


        view作用域是生命周期介于request和session之间的一个作用范围。当一个Spring Bean(一般来说是Action层面的Bean)被标注作用域为view的时候,Spring会在需要用到这个Bean的时候创建之,然后,在当前页面没有发生整页的reload、跳转的情况下,这个bean一直存在。所谓整页reload、跳转说的就是我们普通的表单提交,URL GET请求。发生除此之外的其他请求(目前能想到的其实也就是一种:Ajax请求)的时候,前面创建出来的bean对象一直存在。

        我们在一个列表页面加载的时候,使用一个view作用域的bean作为其action对象,于是加载完成后,要对列表中的某些行执行操作的时候,你都不需要再次去查询,因为整个对象集合都依然存在!


        本质上讲,view作用域中的数据时被放在了session中。但是JSF实现了对于这写内容的管理方式,不需要使用人员关心。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值