Package rife.web

Class PagedNavigation

java.lang.Object
rife.web.PagedNavigation

public class PagedNavigation extends Object
This class provides utility methods to generate navigation for paged lists.

The generation of the navigation depends on a collection of block and value IDs that should be defined in a template. Following is a table of all the IDs and their purpose:

ID Description
<!--b nav:firstRange--><!--/b--> Provides the content that will be used to jump to the first range. This block has to contain a nav:route value that will be replaced with the actual URL that will trigger the paging behaviour.
<!--b nav:firstRange:disabled--><!--/b--> Provides the content that will be used when jumping to the first range is not appropriate, for instance when the first range is already the current offset.
<!--b nav:previousRange--><!--/b--> Provides the content that will be used to jump to the previous range according to the current offset. This block has to contain a nav:route value that will be replaced with the actual URL that will trigger the paging behaviour.
<!--b nav:previousRange:disabled--><!--/b--> Provides the content that will be used when jumping to the previous range is not appropriate, for instance when the first range is the current offset.
<!--b nav:absoluteRange--><!--/b--> Provides the content that will be used to jump directly to each individual range. This block has to contain a nav:route value that will be replaced with the actual URL that will trigger the paging behaviour.
<!--b nav:absoluteRange:disabled--><!--/b--> Provides the content that will be used when jumping directly to a specific individual range is not appropriate, for instance when that range corresponds to the current offset.
<!--b nav:nextRange--><!--/b--> Provides the content that will be used to jump to the next range according to the current offset. This block has to contain a nav:route value that will be replaced with the actual URL that will trigger the paging behaviour.
<!--b nav:nextRange:disabled--><!--/b--> Provides the content that will be used when jumping to the next range is not appropriate, for instance when the last range is the current offset.
<!--b nav:lastRange--><!--/b--> Provides the content that will be used to the last range. This block has to contain a nav:route value that will be replaced with the actual URL that will trigger the paging behaviour.
<!--b nav:lastRange:disabled--><!--/b--> Provides the content that will be used when jumping to the last range is not appropriate, for instance when the last range is already the current offset.
<!--v nav:route/--> Will be replaced with the actual URL that will trigger the paging behaviour.
<!--v nav:rangeCount/--> Will contain the number of ranges that are needed to display all the information that is paged. This value is optional.
<!--v nav:firstRange/--> Will contain the content that allows to jump to the first range. This corresponds to the beginning of the paged data.
<!--v nav:previousRange/--> Will contain the content that allows to jump to the previous range according to the current offset.
<!--v nav:absoluteRanges/--> Will contain the content that allows to jump directly to each individual range that is available.
<!--v nav:nextRange/--> Will contain the content that allows to jump to the next range according to the current offset.
<!--v nav:lastRange/--> Will contain the content that allows to jump to the last range. This corresponds to the end of the paged data.

Besides these template conventions, you also have to provide one exit and one output that will be used to create the links that will perform the actual paging behaviour of the navigation. By default, the change_offset exit and the offset output will be used. It's up to you to create the datalink and flowlink and to correctly handle the offset value when it changes.

A very basic paged navigation could for example be defined like this:

 <!--b nav:firstRange--><a href="{{v nav:route/}}">&lt;&lt;</a><!--/b-->
 <!--b nav:firstRange:disabled-->&lt;&lt;<!--/b-->
 <!--b nav:previousRange--><a href="{{v nav:route/}}">&lt;</a><!--/b-->
 <!--b nav:previousRange:disabled-->&lt;<!--/b-->
 <!--b nav:absoluteRange-->&nbsp;<a href="{{v nav:route/}}"><!--v absoluteRangeText/--></a>&nbsp;<!--/b-->
 <!--b nav:absoluteRange:disabled-->&nbsp;<!--v absoluteRangeText/-->&nbsp;<!--/b-->
 <!--b nav:nextRange--><a href="{{v nav:route/}}">&gt;</a><!--/b-->
 <!--b nav:nextRange:disabled-->&gt;<!--/b-->
 <!--b nav:lastRange--><a href="{{v nav:route/}}">&gt;&gt;</a><!--/b-->
 <!--b nav:lastRange:disabled-->&gt;&gt;<!--/b-->

 Pages: <!--v nav:rangeCount/--> ( <!--v nav:firstRange/--> <!--v nav:previousRange/--> <!--v nav:nextRange/--> <!--v nav:lastRange/--> | <!--v nav:absoluteRanges/--> )
 

Which could result in the following output where all the underlined parts are clickable and will trigger the change_offset exit and provide a new corresponding value for the offset output:

Pages: 9 ( << < > >> | 1 2 3 4 5 6 7 8 9 )

Since:
1.1
  • Field Details

    • PREFIX_NAV

      public static String PREFIX_NAV
    • SUFFIX_DISABLED

      public static String SUFFIX_DISABLED
    • ID_ROUTE_OFFSET

      public static String ID_ROUTE_OFFSET
    • ID_RANGE_COUNT

      public static String ID_RANGE_COUNT
    • ID_ABSOLUTE_RANGE_TEXT

      public static String ID_ABSOLUTE_RANGE_TEXT
    • ID_FIRST_RANGE

      public static String ID_FIRST_RANGE
    • ID_PREVIOUS_RANGE

      public static String ID_PREVIOUS_RANGE
    • ID_ABSOLUTE_RANGES

      public static String ID_ABSOLUTE_RANGES
    • ID_ABSOLUTE_RANGE

      public static String ID_ABSOLUTE_RANGE
    • ID_NEXT_RANGE

      public static String ID_NEXT_RANGE
    • ID_LAST_RANGE

      public static String ID_LAST_RANGE
    • ID_FIRST_RANGE_DISABLED

      public static String ID_FIRST_RANGE_DISABLED
    • ID_PREVIOUS_RANGE_DISABLED

      public static String ID_PREVIOUS_RANGE_DISABLED
    • ID_ABSOLUTE_RANGE_DISABLED

      public static String ID_ABSOLUTE_RANGE_DISABLED
    • ID_NEXT_RANGE_DISABLED

      public static String ID_NEXT_RANGE_DISABLED
    • ID_LAST_RANGE_DISABLED

      public static String ID_LAST_RANGE_DISABLED
    • DEFAULT_PARAMETER

      public static String DEFAULT_PARAMETER
  • Constructor Details

    • PagedNavigation

      public PagedNavigation()
  • Method Details

    • generate

      public static void generate(Context context, Template template, long count, int limit, long offset, int span)
      Generates the paged navigation for the given context, template and range configuration. The default parameter offset will be used when generating the links.
      Parameters:
      context - The context that is populating the template. Its exit will be triggered and its output will be set.
      template - The template that will be used for the generation of the navigation.
      count - The total number of items that are being paged.
      limit - The maximum of items that will be shown in a range on a page.
      offset - The starting offset of the range that is currently visible.
      span - The maximum number of ranges that will be shown as immediately accessible absolute ranges.
      Since:
      1.1
    • generate

      public static void generate(Context context, Template template, long count, int limit, long offset, int span, String parameter)
      Generates the paged navigation for the given context, template and range configuration. This version allows you to provide your own name for the parameter that will be used when generating the links.
      Parameters:
      context - The context that is populating the template, whose exit will be triggered and whose output will be set.
      template - The template that will be used for the generation of the navigation.
      count - The total number of items that are being paged.
      limit - The maximum of items that will be shown in a range on a page.
      offset - The starting offset of the range that is currently visible.
      span - The maximum number of ranges that will be shown as immediately accessible absolute ranges.
      parameter - The name of the parameter that will contain the value of the new range offset when the url if followed.
      Since:
      1.1