|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.Component
org.apache.wicket.MarkupContainer
org.apache.wicket.markup.html.WebMarkupContainer
org.apache.wicket.markup.repeater.AbstractRepeater
org.apache.wicket.markup.html.list.Loop
org.apache.wicket.markup.html.navigation.paging.PagingNavigation
public class PagingNavigation
A navigation for a PageableListView that holds links to other pages of the PageableListView.
For each row (one page of the list of pages) a PagingNavigationLink
will be added that
contains a Label
with the page number of that link (1..n).
<td wicket:id="navigation"> <a wicket:id="pageLink" href="SearchCDPage.html"> <span wicket:id="pageNumber">1</span> </a> </td>thus renders like:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Override method populateItem to customize the rendering of the navigation. For instance:
protected void populateItem(LoopItem loopItem) { final int page = loopItem.getIteration(); final PagingNavigationLink link = new PagingNavigationLink("pageLink", pageableListView, page); if (page > 0) { loopItem.add(new Label("separator", "|")); } else { loopItem.add(new Label("separator", "")); } link.add(new Label("pageNumber", String.valueOf(page + 1))); link.add(new Label("pageLabel", "page")); loopItem.add(link); }With:
<span wicket:id="navigation"> <span wicket:id="separator"></span> <a wicket:id="pageLink" href="#"> <span wicket:id="pageLabel"></span><span wicket:id="pageNumber"></span> </a> </span>renders like:
page1 | page2 | page3 | page4 | page5 | page6 | page7 | page8 | page9Assuming a PageableListView with 1000 entries and not more than 10 lines shall be printed per page, the navigation bar would have 100 entries. Because this is not feasible PagingNavigation's navigation bar is pageable as well.
The page links displayed are automatically adjusted based on the number of page links to be displayed and a margin. The margin makes sure that the page link pointing to the current page is not at the left or right end of the page links currently printed and thus providing a better user experience.
Use setMargin() and setViewSize() to adjust the navigation's bar view size and margin.
Please
for a ready made component which already includes links to the first,
previous, next and last page.
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.list.Loop |
---|
Loop.LoopItem |
Nested classes/interfaces inherited from class org.apache.wicket.Component |
---|
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor<T extends Component>, Component.VisibilityChange |
Field Summary | |
---|---|
protected IPagingLabelProvider |
labelProvider
The label provider for the text that the links should be displaying. |
protected IPageable |
pageable
The PageableListView this navigation is navigating. |
Fields inherited from class org.apache.wicket.Component |
---|
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
PagingNavigation(String id,
IPageable pageable)
Constructor. |
|
PagingNavigation(String id,
IPageable pageable,
IPagingLabelProvider labelProvider)
Constructor. |
Method Summary | |
---|---|
int |
getMargin()
Gets the margin, default value is half the view size, unless explicitly set. |
String |
getSeparator()
Gets the seperator. |
protected int |
getStartIndex()
Allow subclasses replacing populateItem to calculate the current page number |
int |
getViewSize()
Gets the view size (is fixed by user). |
protected AbstractLink |
newPagingNavigationLink(String id,
IPageable pageable,
int pageIndex)
Factory method for creating page number links. |
protected void |
onBeforeRender()
Called just before a component is rendered. |
protected void |
populateItem(Loop.LoopItem loopItem)
Populate the current cell with a page link (PagingNavigationLink) enclosing the page number the link is pointing to. |
protected void |
renderItem(Loop.LoopItem loopItem)
Renders the page link. |
void |
setMargin(int margin)
Sets the margin. |
void |
setSeparator(String separator)
Sets the seperator. |
void |
setViewSize(int size)
view size of the navigation bar. |
Methods inherited from class org.apache.wicket.markup.html.list.Loop |
---|
getIterations, newItem, onPopulate, renderChild, renderIterator |
Methods inherited from class org.apache.wicket.markup.repeater.AbstractRepeater |
---|
onRender |
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer |
---|
getMarkupType, getWebPage, getWebRequest |
Methods inherited from class org.apache.wicket.MarkupContainer |
---|
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onAfterRenderChildren, onComponentTagBody, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, renderNext, replace, setDefaultModel, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected IPageable pageable
protected IPagingLabelProvider labelProvider
Constructor Detail |
---|
public PagingNavigation(String id, IPageable pageable)
id
- See Componentpageable
- The underlying pageable component to navigatepublic PagingNavigation(String id, IPageable pageable, IPagingLabelProvider labelProvider)
id
- See Componentpageable
- The underlying pageable component to navigatelabelProvider
- The label provider for the text that the links should be displaying.Method Detail |
---|
public int getMargin()
public String getSeparator()
public int getViewSize()
public void setViewSize(int size)
size
- public void setMargin(int margin)
margin
- the marginpublic void setSeparator(String separator)
separator
- the seperatorprotected void onBeforeRender()
Component
NOTE: If you override this, you *must* call super.onBeforeRender() within
your implementation.
Because this method is responsible for cascading Component.onBeforeRender()
call to its
children it is strongly recommended that super call is made at the end of the override.
onBeforeRender
in class AbstractRepeater
Component.onBeforeRender()
protected final int getStartIndex()
protected void populateItem(Loop.LoopItem loopItem)
populateItem
in class Loop
loopItem
- The iteration of the loopLoop.populateItem(Loop.LoopItem)
protected AbstractLink newPagingNavigationLink(String id, IPageable pageable, int pageIndex)
id
- the component id.pageable
- the pageable for the linkpageIndex
- the page index the link points to
protected void renderItem(Loop.LoopItem loopItem)
renderItem
in class Loop
loopItem
- The loop iterationLoop.renderItem(Loop.LoopItem)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |