JSF页面的生命周期及ADF页面的生命周期
How JSF Page Lifecycle and ADF Page Lifecycle Phases Relate
iterator 刷新是怎么回事? (What does refreshing an iterator binding mean anyway? )
iterator binding 底层指向一个row set iterator,考虑到性能的原因,在每个请求request 结束后,它就会会释放所有 row set iterator引用。在下一个request 阶段,Iterator bindings 被再一次刷新,被指向一个“live"的 Row set Iterator,这个Row set Iterator 跟踪的集合的当前对象。刷新操作访问底层的 Row Set Iterator, 把binding与 Row set iterator重新结合起来。
如果Iterator bindings不刷新,bindings就不会被指向到Row Set Iterator ,关联了这个iterator的Value binding 就得不到所希望的值。
例如,如果你希望一个查询页面,在初次呈现时,不显示任何数据:
#{adfFacesContext.postback == true}
有效Iterator 的 Refresh值如下:
1、ifNeeded:默认,在prepareModel和prepareRender阶段都会刷新
2、prepareModel:仅在prepareModel phase
3、renderModel:仅在 prepareRender phase
4、Never :从不刷新
你可以通过调用iterator binding的getRowSetIterator()来刷新binding(其他的refresh值与Iterator binding无关)。
刷新一个Iterator Binding是 不会强制Query重新执行 Refreshing an Iterator Binding Does Not Forcibly Re-Execute Query
理解这一点是重要的,不是每一次刷新都会执行查询的,在一个用户工作单元(during a particular user's unit of work),在 Row set Iterator 第一次被访问时,如果Row Set Iterator尚未执行,就会自动地调用查询。接下来的同一个逻辑工作单元(logic unit of work) 的 request,仅仅是刷新,将binding 重新绑定到底层的Row set Iterator.如果想要强制执行查询,你可以执行build-in的Excute方法,或者调用Iterator binding 的 executeQuery() 方法 。
Correctly Configuring Refresh Property of InvokeAction Executables
正确的配置InvokeAction的刷新属性:
invokeAction binding 用来触发build-in Operation或调用用户自定义方法。每个 invokeAction 有一个id属性,另外还有三个属性:
1、 Binds property controls what the invokeAction will do if it fires Its value is the name of an action binding or method action binding in the same binding container.
2、Refresh property controls when the invokeAction will invoke the action binding To have it fire during the ADF page lifecycle's:
prepareModel phase, use Refresh=prepareModel
prepareRender phase, use Refresh=renderModel
prepareModel and prepareRender phases, use Refresh=ifNeeded
3、The RefreshCondition property can be used to control whether it will fire at all
ADF生命周期中的 prepareModel 阶段和 prepareRender 阶段,一个位于JSF生命周期的invokeApplication阶段前,一个位于其后,在invokeApplication后action已经执行,如果你希望InvokeAction在这个时候之下可以这样设置Refresh:
Refresh="renderModel"
If the invokeAction binds to a method action binding that accepts parameters, then two additional values can be supplied for the Refresh property: prepareModelIfNeeded and renderModelIfNeeded. These have the same meaning as their companion settings without the *IfNeeded suffix, except that they perform an ptimization to compare the current set of evaluated parameter values with the set that was used to invoke the method action binding the previous time. If the parameter values for the current invocation are exactly the same as the ones used previously, the invokeAction does not invoke its bound method action binding.
注意:默认设置,Iterator 被刷新两遍,而InvokeAction被重复执行,Oracle推荐要么使用适当的RefreshCondition 表达式,或者改变默认的Refesh值。