Class PagingNavigation
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IMetadataContext<Serializable,
,Component> IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
- Direct Known Subclasses:
AjaxPagingNavigation
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
- Author:
- Jonathan Locke, Eelco Hillenius, Juergen Donnerstag
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected IPagingLabelProvider
The label provider for the text that the links should be displaying.protected IPageable
The PageableListView this navigation is navigating.Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
Constructor Summary
ConstructorDescriptionPagingNavigation
(String id, IPageable pageable) Constructor.PagingNavigation
(String id, IPageable pageable, IPagingLabelProvider labelProvider) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionlong
Gets the margin, default value is half the view size, unless explicitly set.Gets the seperator.protected final long
Allow subclasses replacing populateItem to calculate the current page numberint
Gets the view size (is fixed by user).protected AbstractLink
newPagingNavigationLink
(String id, IPageable pageable, long pageIndex) Factory method for creating page number links.protected void
Called on all components before any component is rendered.protected void
populateItem
(LoopItem loopItem) Populate the current cell with a page link (PagingNavigationLink) enclosing the page number the link is pointing to.protected void
renderItem
(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
dequeue, getMarkup, onBeforeRender, onRender
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onDetach, onInitialize, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onComponentTag, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
pageable
The PageableListView this navigation is navigating. -
labelProvider
The label provider for the text that the links should be displaying.
-
-
Constructor Details
-
Method Details
-
getMargin
Gets the margin, default value is half the view size, unless explicitly set.- Returns:
- the margin
-
getSeparator
Gets the seperator.- Returns:
- the seperator
-
getViewSize
Gets the view size (is fixed by user).- Returns:
- view size
-
setViewSize
view size of the navigation bar.- Parameters:
size
-
-
setMargin
Sets the margin.- Parameters:
margin
- the margin
-
setSeparator
Sets the seperator. Null meaning, no separator at all.- Parameters:
separator
- the seperator
-
onConfigure
Description copied from class:Component
Called on all components before any component is rendered. This method should be used to configure such things as visibility and enabled flags.Overrides must call
super.onConfigure()
, usually before any other codeNOTE: Component hierarchy should not be modified inside this method, instead it should be done in
Component.onBeforeRender()
NOTE: Why this method is preferrable to directly overriding
Component.isVisible()
andComponent.isEnabled()
? Because those methods are called multiple times even for processing of a single request. If they contain expensive logic they can slow down the response time of the entire page. Further, overriding those methods directly on form components may lead to inconsistent or unexpected state depending on when those methods are called in the form processing workflow. It is a better practice to push changes to state rather than pull.NOTE: If component's visibility or another property depends on another component you may call
other.configure()
followed byother.isVisible()
as mentioned inComponent.configure()
javadoc.NOTE: Why should
Component.onBeforeRender()
not be used for this? Because if a component's visibility is controlled insideComponent.onBeforeRender()
, once invisible the component will never become visible again.- Overrides:
onConfigure
in classComponent
-
getStartIndex
Allow subclasses replacing populateItem to calculate the current page number- Returns:
- start index
-
populateItem
Populate the current cell with a page link (PagingNavigationLink) enclosing the page number the link is pointing to. Subclasses may provide there own implementation adding more sophisticated page links.- Specified by:
populateItem
in classLoop
- Parameters:
loopItem
- The iteration of the loop- See Also:
-
renderItem
Renders the page link. Add the separator if not the last page link- Overrides:
renderItem
in classLoop
- Parameters:
loopItem
- The loop iteration- See Also:
-