Interface IPager<S,T>

Type Parameters:
S - The type of source objects (e.g., IDs or items).
T - The type of target objects (e.g., fully loaded objects).
All Known Implementing Classes:
SimplePager

public interface IPager<S,T>
Interface representing a pager for managing pagination of items.
  • Method Details

    • withBaseUrl

      IPager<S,T> withBaseUrl(String baseUrl)
      Allows to update the base url of the pager in case this url should be dynamic.
      Returns:
      The IPager instance with the updated base URL
    • withItemsPerPage

      IPager<S,T> withItemsPerPage(int defaultItemsPerPage)
      Sets the default number of items per page.
      Parameters:
      defaultItemsPerPage - The default number of items per page.
      Returns:
      The updated IPager instance.
    • withIdList

      IPager<S,T> withIdList(List<S> idList)
      Sets the list of IDs of type . This list will be used to load the objects of type through the `getPaginatedListModel` method with a delegate function.
      Parameters:
      idList - The list of IDs to set.
      Returns:
      The updated IPager instance.
    • withListItem

      IPager<S,T> withListItem(List<S> listItem)
      Sets the list of items directly. This method should be used when the pager is of type `IPager<S, Void>` and no delegate function is involved during page retrieval.
      Parameters:
      listItem - The list of items to set.
      Returns:
      The updated IPager instance.
    • populateModels

      IPaginator<S> populateModels(jakarta.servlet.http.HttpServletRequest request, Models models, Locale locale)
      Populates the given Models object with pagination data.
      Parameters:
      request - The HTTP request object.
      models - The Models object to populate.
      locale - The locale for internationalization.
    • populateModels

      IPaginator<S> populateModels(jakarta.servlet.http.HttpServletRequest request, Models models, fr.paris.lutece.util.function.SerializableFunction<List<S>,List<T>> delegate, Locale locale)
      Populates the given Models object with pagination data using a delegate function.
      Parameters:
      request - The HTTP request object.
      models - The Models object to populate.
      delegate - A function that takes a list of source objects and returns a list of target objects.
      locale - The locale for internationalization.
    • getPaginator

      Optional<IPaginator<S>> getPaginator()
      Retrieves the optional paginator instance associated with this pager.
      Returns:
      An Optional containing the IPaginator instance if available, or an empty Optional if not.