| java.lang.Object com.uwyn.rife.site.PagedNavigation
PagedNavigation | public class PagedNavigation (Code) | | 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 an EXIT:QUERY 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 an EXIT:QUERY
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 an EXIT:QUERY 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 an EXIT:QUERY
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 an EXIT:QUERY 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: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 'EXIT:QUERY:change_offset'/]"><<</a><!--/B-->
<!--B 'NAV:FIRSTRANGE:DISABLED'--><<<!--/B-->
<!--B 'NAV:PREVIOUSRANGE'--><a href="[!V 'EXIT:QUERY:change_offset'/]"><</a><!--/B-->
<!--B 'NAV:PREVIOUSRANGE:DISABLED'--><<!--/B-->
<!--B 'NAV:ABSOLUTERANGE'--> <a href="[!V 'EXIT:QUERY:change_offset'/]"><!--V 'ABSOLUTERANGE_TEXT'/--></a> <!--/B-->
<!--B 'NAV:ABSOLUTERANGE:DISABLED'--> <!--V 'ABSOLUTERANGE_TEXT'/--> <!--/B-->
<!--B 'NAV:NEXTRANGE'--><a href="[!V 'EXIT:QUERY:change_offset'/]">></a><!--/B-->
<!--B 'NAV:NEXTRANGE:DISABLED'-->><!--/B-->
<!--B 'NAV:LASTRANGE'--><a href="[!V 'EXIT:QUERY:change_offset'/]">>></a><!--/B-->
<!--B 'NAV:LASTRANGE:DISABLED'-->>><!--/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 )
The element that displays the list and calls the navigation generation
method could for example be like this:
public class List extends Element
{
public final static int LIMIT = 10;
public final static int SPAN = 5;
public void processElement()
{
Template t = getHtmlTemplate("article.list");
DatabaseArticles manager = DatabaseArticlesFactory.getInstance();
int count = manager.countArticles();
if (0 == count) t.setBlock("content", "noarticles");
else
{
int offset = getInputInt("offset", 0);
PagedNavigation.generateNavigation(this, t, count, LIMIT, offset, SPAN);
Collection<Article> articles = manager.listArticles(LIMIT, offset);
for (Article article : articles)
{
t.setBean(article);
t.appendBlock("articles", "article");
}
}
print(t);
}
}
|
Method Summary | |
public static void | generateNavigation(ElementSupport element, Template template, long count, int limit, long offset, int span) Generates the paged navigation for the given element, template and
range configuration. | public static void | generateNavigation(ElementSupport element, Template template, long count, int limit, long offset, int span, String exit, String output) Generates the paged navigation for the given element, template and
range configuration. | public static void | generateNavigation(ElementSupport element, Template template, long count, int limit, long offset, int span, String exit, String output, String pathInfo) Generates the paged navigation for the given element, template and
range configuration. |
ID_ABSOLUTERANGES | public static String ID_ABSOLUTERANGES(Code) | | |
ID_ABSOLUTERANGE_DISABLED | public static String ID_ABSOLUTERANGE_DISABLED(Code) | | |
ID_ABSOLUTERANGE_TEXT | public static String ID_ABSOLUTERANGE_TEXT(Code) | | |
ID_FIRSTRANGE_DISABLED | public static String ID_FIRSTRANGE_DISABLED(Code) | | |
ID_LASTRANGE_DISABLED | public static String ID_LASTRANGE_DISABLED(Code) | | |
ID_NEXTRANGE_DISABLED | public static String ID_NEXTRANGE_DISABLED(Code) | | |
ID_PREVIOUSRANGE_DISABLED | public static String ID_PREVIOUSRANGE_DISABLED(Code) | | |
generateNavigation | public static void generateNavigation(ElementSupport element, Template template, long count, int limit, long offset, int span)(Code) | | Generates the paged navigation for the given element, template and
range configuration. The default exit change_offset and
the default output offset will be used when generating the
links.
Parameters: element - The element that is populating the template. Its exitwill be triggered and its output will be set. Parameters: template - The template that will be used for the generation ofthe navigation. Parameters: count - The total number of items that are being paged. Parameters: limit - The maximum of items that will be shown in a range on apage. Parameters: offset - The starting offset of the range that is currentlyvisible. Parameters: span - The maximum number of ranges that will be shown asimmediately accesible absolute ranges. |
generateNavigation | public static void generateNavigation(ElementSupport element, Template template, long count, int limit, long offset, int span, String exit, String output)(Code) | | Generates the paged navigation for the given element, template and
range configuration. This version allows you to provide your own names
for the exit and the output that will be used when generating the
links.
Parameters: element - The element that is populating the template, whose exitwill be triggered and whose output will be set. Parameters: template - The template that will be used for the generation ofthe navigation. Parameters: count - The total number of items that are being paged. Parameters: limit - The maximum of items that will be shown in a range on apage. Parameters: offset - The starting offset of the range that is currentlyvisible. Parameters: span - The maximum number of ranges that will be shown asimmediately accesible absolute ranges. Parameters: exit - The name of the exit that has to be used to trigger anoffset change. Parameters: output - The name of the output that will contain the value of thenew range offset when the exit is triggered. |
generateNavigation | public static void generateNavigation(ElementSupport element, Template template, long count, int limit, long offset, int span, String exit, String output, String pathInfo)(Code) | | Generates the paged navigation for the given element, template and
range configuration. This version allows you to provide your own names
for the exit and the output that will be used when generating the
links.
Parameters: element - The element that is populating the template, whose exitwill be triggered and whose output will be set. Parameters: template - The template that will be used for the generation ofthe navigation. Parameters: count - The total number of items that are being paged. Parameters: limit - The maximum of items that will be shown in a range on apage. Parameters: offset - The starting offset of the range that is currentlyvisible. Parameters: span - The maximum number of ranges that will be shown asimmediately accesible absolute ranges. Parameters: exit - The name of the exit that has to be used to trigger anoffset change. Parameters: output - The name of the output that will contain the value of thenew range offset when the exit is triggered. Parameters: pathInfo - The pathinfo to be applied to the exit used to trigger an offset change |
|
|