XPojoIterator is a special model node that handles an iteration over POJO arrays and collections. The iterator by default is assigned to each array/collection and placed under the "iterator" subpath. For example: if pojo/allUsers path points to a XPojoModel node encapsulating either an array or collection then the associated iterator is located at the pojo/allUsers/iterator path.
The iterator exposes four methods:
- first() - moves the iteration to the first element of the underlying collection/array.
- last() - moves the iteration to the last element of the underlying collection/array.
- next() - moves the iteration to the next element of the underlying collection/array.
- prev() - moves the iteration to the previous element of the underlying collection/array.
Each of the methods above can be invoked be evaluating the ...iterator/[method_name] path, e. g. pojo/allUsers/iterator/next(), pojo/allUsers/iterator/prev(), etc.
Properties of the iteration's current element (POJO) are available under ...iterator/[property_name] paths, e.g. pojo/allUsers/iterator/firstname points to a POJO model node wrapping the current user's firstname. Combining this with a facility to bind action events to POJO methods allows to create "UI iterators" over arrays and collection with no user code needed. A simple example of that could be as follows:
There are no comments on this page. [Add comment]