We
all may know what refreshing an iterator is. It is the process in which an
iterator binding rebinds itself to a live row set iterator which is tracking
the current row of same data collection.
Having
a strong knowledge on ADF Life Cycle might help before reading this article.
Please read in the provided link.
Now
By default, this happens only once, when the iterator is first accessed by the
client layer during the life cycle.
To
force the iterator binding to refresh its row set iterator earlier in the
lifecyle, you can set the refresh attribute on the iterator binding to a value
other than the default.
The
refresh and refreshCondition attributes are used to determine when and whether
to invoke an executable, such as an iterator binding, or an invokeAction.
Different
Values for refresh property
By default, when JDeveloper adds an executable to a
page definition (for example, when you drop an operation as a command
component), the refresh attribute for the executable binding is set to deferred.
We can change this into the following values:
·
deffered: It
enforces execution whenever the binding is accessed the first time. If no
refreshCondition value exists, the executable is invoked. If a value for
refreshCondition exists, then that value is evaluated as an EL expression, and
if the return value of the evaluation is true, then the executable is invoked
·
prepareModel: It
will get refreshed during the Prepare Model phase of ADF life cycle.
·
renderModel: It
will get refreshed during the Prepare Render phase of ADF life cycle.
·
ifNeeded: During
the Prepare Model and Prepare Render phases, only if needed. For iterators, the
refresh is considered needed if the binding has not yet been refreshed. To
determine if the execution is needed for an invokeAction, the framework
compares the current set of evaluated parameter values with the set that was
used to invoke the method action binding previously. If the parameter values
for the current invocation are exactly the same as those used previously, the
invokeAction does not invoke its bound method action binding.
·
prepareModelIfNeeded & prepareRenderIfNeeded: Same as ifNeeded, except that it is executed during
the named phase.
·
never: Not
valid for invokeAction executables. For iterators, the iterator will never be
refreshed. Use when your own code calls getRowSetIterator() on the iterator
binding.
·
always: Not
valid for invokeAction executables. For iterators, the iterator will always be
refreshed (potentially multiple times) during both the Prepare Model and
Prepare Render phases, as well as during the Update Model phase.
·
refreshAfter: Use
to handle dependencies between executables. For example, you can set the
condition so that this executable refreshes after another executable
Important Note –
Distinction Between prepareModel & renderModel
prepareModel comes before JSF’ Invoke application
phase.
renderModel comes after JSF’ invoke application phase.
So if you want your iterator to get refreshed after
the execution of the action listeners then you should use renderModel.
Hi Pankaj,
ReplyDeletemay you please explain refreshAfter with an example
Thanks
Somesh
Thanks Pankaj! Can you please explain the distinction between prepareModel and renderModel again? There's a typo there and I guess you meant one comes before the application phase invocation and the other after. Please clarify.
ReplyDelete