|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.site.PagedNavigation
public class PagedNavigation
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);
}
}
| Field Summary | |
|---|---|
static String |
DEFAULT_EXIT
|
static String |
DEFAULT_OUTPUT
|
static String |
ID_ABSOLUTERANGE
|
static String |
ID_ABSOLUTERANGE_DISABLED
|
static String |
ID_ABSOLUTERANGE_TEXT
|
static String |
ID_ABSOLUTERANGES
|
static String |
ID_FIRSTRANGE
|
static String |
ID_FIRSTRANGE_DISABLED
|
static String |
ID_LASTRANGE
|
static String |
ID_LASTRANGE_DISABLED
|
static String |
ID_NEXTRANGE
|
static String |
ID_NEXTRANGE_DISABLED
|
static String |
ID_PREVIOUSRANGE
|
static String |
ID_PREVIOUSRANGE_DISABLED
|
static String |
ID_RANGECOUNT
|
static String |
PREFIX_NAV
|
static String |
SUFFIX_DISABLED
|
| Constructor Summary | |
|---|---|
PagedNavigation()
|
|
| Method Summary | |
|---|---|
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. |
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. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String PREFIX_NAV
public static String SUFFIX_DISABLED
public static String ID_RANGECOUNT
public static String ID_ABSOLUTERANGE_TEXT
public static String ID_FIRSTRANGE
public static String ID_PREVIOUSRANGE
public static String ID_ABSOLUTERANGES
public static String ID_ABSOLUTERANGE
public static String ID_NEXTRANGE
public static String ID_LASTRANGE
public static String ID_FIRSTRANGE_DISABLED
public static String ID_PREVIOUSRANGE_DISABLED
public static String ID_ABSOLUTERANGE_DISABLED
public static String ID_NEXTRANGE_DISABLED
public static String ID_LASTRANGE_DISABLED
public static String DEFAULT_EXIT
public static String DEFAULT_OUTPUT
| Constructor Detail |
|---|
public PagedNavigation()
| Method Detail |
|---|
public static void generateNavigation(ElementSupport element,
Template template,
long count,
int limit,
long offset,
int span)
change_offset and
the default output offset will be used when generating the
links.
element - The element 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 accesible absolute ranges.
public static void generateNavigation(ElementSupport element,
Template template,
long count,
int limit,
long offset,
int span,
String exit,
String output)
element - The element 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 accesible absolute ranges.exit - The name of the exit that has to be used to trigger an
offset change.output - The name of the output that will contain the value of the
new range offset when the exit is triggered.
public static void generateNavigation(ElementSupport element,
Template template,
long count,
int limit,
long offset,
int span,
String exit,
String output,
String pathInfo)
element - The element 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 accesible absolute ranges.exit - The name of the exit that has to be used to trigger an
offset change.output - The name of the output that will contain the value of the
new range offset when the exit is triggered.pathInfo - The pathinfo to be applied to the exit used to trigger an offset change
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||