pageFlowScope、backingBeanScope、viewScope、applicationScope、sessionScope、requestScope
2015-04-01 16:19
267 查看
pageFlowScope、backingBeanScope、viewScope、applicationScope、sessionScope、requestScope
分类: java2012-08-0208:49 499人阅读 评论(0) 收藏 举报
beanobjectsessionspringjsfcomponents
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实现了对于这写内容的管理方式,不需要使用人员关心。
相关文章推荐
- pageFlowScope、backingBeanScope、viewScope、applicationScope、sessionScope、requestScope
- ADF12C viewScope,pageFlowScope,requestScope,backingBeanScope
- 4.EL入门:pageScope、requestScope、sessionScope 和applicationScope
- Scope的几种分类-Session,request,pageflow,view,backingbean
- pageScope、requestScope、sessionScope、applicationScope的区别
- ADF HOW TO: How to refresh page/region in backing bean
- ADF HOW TO: How to refresh page/region in backing bean
- backing bean与pagedef文件
- 4 ways to pass parameter from JSF page to backing bean
- 深入浅出Java MVC(Model View Controller) ---- (JSP + servlet + javabean实例)
- spring中bean的scope
- UIScrollView--UIPageControl
- android ViewPager,ViewFlipper,ViewFlow实现左右滑动
- viewpager的setOffscreenPageLimit方法有什么作用
- Android-ViewPagerIndicator框架使用——IconPageIndicator
- bean元素scope属性配置Bean的作用域
- ViewPage Fragment点击切换
- Fragment+ViewPage 替换TabActivity
- 关于ViewPager、ViewFilpper、ViewFlow三种实现水平向滑动方式的比较
- PageIndicatorView