LSPS documentation logo
LSPS Documentation
Repeater (forms::Repeater)

The Repeater component serves to display the same component repeatedly over a set of data defined by Repeater's data source. Note that unlike Tables, TreeTables, and Grids, Repeaters do not load their data source objects lazily.

Defining a Repeater

To create a Repeater with your content, do the following:

  1. Insert the Repeater component into your Form.
  2. In the Properties view of the Repeater, define its properties:
    1. Select the Vertical option to display the repeated content vertically: leave blank to display the components horizontally.
    2. Define the data source type and value.
    3. If applicable, change the data type of the iterator in the Type field next to the iterator name.
  3. Insert form components into the Repeater form: use the iterator name to work with the current data-source object.
repeaterDefinition.png

Paging in Repeater

To implement paging in a Repeater, do the following:

  1. Set the required page size on the Repeater with setPageSize()
  2. Set the required start index on the Repeater with setStartIndex().
  3. Create a component, that will implement the next page functionality, for example, a Next button with a click listener:
    { e ->
       //set new start index when the user clicks previous
       myRepeater.setStartIndex(myRepeater.getStartIndex() + myRepeater.getPageSize());
       myRepeater.refresh();
    }
  4. Create a component, that will implement the previous page functionality, for example, a Next button with a click listener:
    { e ->
       //set new start index when the user clicks previous
       myRepeater.setStartIndex(myRepeater.getStartIndex() - myRepeater.getPageSize());
       myRepeater.refresh();
    }
  5. Create a form method that will disable and enable the next and previous page functionality when no more previous or next items are available:
    private void refreshButtonEnabled() {
        nextButton.setEnabled( myRepeater.getStartIndex() + myRepeater.getPageSize() < repeaterCollectionDs.size());
        prevButton.setEnabled( not (myRepeater.getStartIndex() - myRepeater.getPageSize() < 0) );
    }