Package fr.paris.lutece.portal.web.util
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 Summary
Modifier and TypeMethodDescriptionRetrieves the optional paginator instance associated with this pager.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.populateModels(jakarta.servlet.http.HttpServletRequest request, Models models, Locale locale) Populates the given Models object with pagination data.withBaseUrl(String baseUrl) Allows to update the base url of the pager in case this url should be dynamic.withIdList(List<S> idList) Sets the list of IDs of type.withItemsPerPage(int defaultItemsPerPage) Sets the default number of items per page.withListItem(List<S> listItem) Sets the list of items directly.
-
Method Details
-
withBaseUrl
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
Sets the default number of items per page.- Parameters:
defaultItemsPerPage- The default number of items per page.- Returns:
- The updated IPager instance.
-
withIdList
Sets the list of IDs of type. This list will be used to load the objects of typethrough the `getPaginatedListModel` method with a delegate function. - Parameters:
idList- The list of IDs to set.- Returns:
- The updated IPager instance.
-
withListItem
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
Optionalcontaining theIPaginatorinstance if available, or an emptyOptionalif not.
-