Class List

java.lang.Object
com.day.cq.wcm.foundation.List

public class List extends Object
Creates a list from a resource for use in the list component.
  • Field Details

  • Constructor Details

    • List

      public List(SlingHttpServletRequest request)
      Creates a List instance based on the specified request.
      Parameters:
      request - The request
    • List

      public List(SlingHttpServletRequest request, PageFilter pageFilter)
      Creates a List instance based on the specified request.
      Parameters:
      request - The request
      pageFilter - Page filter
  • Method Details

    • getResources

      public Iterator<Resource> getResources()
      Deprecated.
      use getPages() instead
      Returns the list items as resources.
      Returns:
      The resources
    • getPages

      public Iterator<Page> getPages()
      Returns the list items as pages, respecting both starting index and maximum number of list items if specified.
      Returns:
      The pages
    • getNodes

      public Iterator<Node> getNodes()
      Returns the list as nodes. This is only the case when an advanced search is run, ie. the source is SOURCE_QUERYBUILDER. Otherwise null will be returned.
      Returns:
      the nodes of a querybuilder search result or null
      Since:
      5.3
    • isOrdered

      public boolean isOrdered()
      States whether the list is ordered.
      Returns:
      true if list is ordered, false otherwise
    • isEmpty

      public boolean isEmpty()
      States whether the list is empty.
      Returns:
      true if list is empty, false otherwise
    • size

      public int size()
      Returns the number of list items.
      Returns:
      The size of the list
    • isPaginating

      public boolean isPaginating()
      States whether the list is paginating, i.e. has a starting index and/or a maximum numbe rof list items per page defined.
      Returns:
      true if list is paginating, false otherwise
    • getPageStart

      public int getPageStart()
      Returns the starting index for list items on this page. Used for pagination.
      Returns:
      The start index of
    • getPageMaximum

      public int getPageMaximum()
      Returns the maximum of list items to return per page. Used for pagination.
      Returns:
      The maximum per page
    • getNextPageLink

      public String getNextPageLink()
      Returns the link to the page with the next set of list items. Used for pagination.
      Returns:
      The link to the next page
    • getPreviousPageLink

      public String getPreviousPageLink()
      Returns the link to the page with the previous set of list items. Used for pagination.
      Returns:
      The link to the previous page
    • setSource

      public void setSource(String src)
      Sets the source for the list. The value can be one of: This is an optional setter, the default value will be taken from the property defined by SOURCE_PROPERTY_NAME.
      Parameters:
      src - The list source
    • setQuery

      public void setQuery(String q)
      Sets the query for the fulltext search.
      Parameters:
      q - The query
    • setQuery

      public void setQuery(String q, String type)
      Sets the query for the search with the specified type (xpath, sql).
      Parameters:
      q - The query
      type - The query type (optional)
    • setStartIn

      public void setStartIn(String start)
      Sets the the of the page to start searching on.
      Parameters:
      start - The start page path
    • getType

      public String getType()
      Returns the type of the list. This can be used to select the script that renders the list items.
      Returns:
      The list type
    • setType

      public void setType(String t)
      Sets the type of the list. This is an optional setter, the default value will be taken from the property defined by TYPE_PROPERTY_NAME.
      Parameters:
      t - The list type
    • setOrderComparator

      public void setOrderComparator(Comparator<Page> obc)
      Sets the comparator used to order the list with. This is an optional setter and overrides #setOrderBy(String).
      Parameters:
      obc - The comparator to order the list with
    • setOrderBy

      public void setOrderBy(String ob)
      Sets the property to order the list by. This is an optional setter, the default value will be taken from the property defined by ORDER_BY_PROPERTY_NAME.
      Parameters:
      ob - The property to order the list by
    • setOrdered

      public void setOrdered(boolean o)
      Sets the list style (numbered or not). This is an optional setter, the default value will be false
      Parameters:
      o - true if list should be rendered with numbered items, false otherwise
    • setLimit

      public void setLimit(int l)
      Sets the limit for list items. This is an optional setter, the default value will be taken from the property defined by LIMIT_PROPERTY_NAME.
      Parameters:
      l - The limit
    • setPageMaximum

      public void setPageMaximum(int pm)
      Sets the maximum list items to return. Enables pagination. This is an optional setter, the default value will be taken from the property defined by PAGE_MAX_PROPERTY_NAME.
      Parameters:
      pm - The maximum number of pages per page
    • setPageStart

      public void setPageStart(int psi)
      Sets the starting index to be respected when returning list items. Used when paginating.
      Parameters:
      psi - The starting index (defaults to 0).
    • setPageIterator

      public void setPageIterator(Iterator<Page> iter)
      Sets the page iterator to generate the list from.
      Parameters:
      iter - The iterator