First page Back Continue Last page Graphics

Programmatically Retaining and Reusing a View Link Accessor Row Set


Notes:

Retaining and Reusing a Row Set

In the lesson titled “Declaratively Customizing Data Services,” you learned how to declaratively retain and reuse a view link accessor row set and why it may be advisable to do so. It is also possible to perform this caching of the row set programmatically.

To use the view link accessor retention feature, generate a Java class for your view object and in that Java class:

1. Override the create() method (the optional @Override annotation tells the compiler that a superclass method is being overridden; if not done correctly, a compile error occurs).

2. Add a line after super.create() that calls the method setViewLinkAccessorRetained(), passing true as the parameter.

Because this is a method of the view definition class ViewDefImpl, this affects all view link accessor attributes for that view object. When this feature is enabled for a view object, because the view link accessor row set is not re­created each time, the current row of its default row set iterator is also retained as a side effect.

Because of this, prior to calling code that iterates through the row set, your code needs to explicitly call the reset() method on the row set that you retrieve from the view link accessor. This resets the current row in its default row set iterator back to just before the first row.