wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From K <kondetiudayki...@gmail.com>
Subject Custom Pagination
Date Thu, 26 Jun 2014 14:55:21 GMT
My Java Code: 

public class CustomPagingNavigator extends PagingNavigator implements
		Serializable {
	
	private static final long serialVersionUID = 1L;
	private PagingNavigation pagingNavigation;
	private final IPageable pageable;
	private final IPagingLabelProvider labelProvider;
	public static final String NAVIGATION_ID = "navigation";

	public CustomPagingNavigator(final String id, final IPageable pageable) {
		this(id, pageable, null);
	}

	public CustomPagingNavigator(String id, IPageable pageable,
			IPagingLabelProvider labelProvider) {
		super(id, pageable, labelProvider);
		this.pageable = pageable;
		this.labelProvider = labelProvider;
	}

	@Override
	protected void onBeforeRender() {
		if (get("first") == null) {
			
			 add(new Label("page1", "Page")); 
			 newNavigation(this.pageable, this.labelProvider);
			  add(new Label("of", " of ")); 
			  add(new Label("total", getPageable().getPageCount())); 

			// Add additional page links
			add(newPagingNavigationLink("first", pageable, 0).add(
					new TitleAppender("PagingNavigator.first")));
			add(newPagingNavigationIncrementLink("prev", pageable, -1).add(
					new TitleAppender("PagingNavigator.previous")));
			add(newPagingNavigationIncrementLink("next", pageable, 1).add(
					new TitleAppender("PagingNavigator.next")));
			add(newPagingNavigationLink("last", pageable, -1).add(
					new TitleAppender("PagingNavigator.last")));
		}
		super.onBeforeRender();
	}

	protected AbstractLink newPagingNavigationIncrementLink(String id,
			IPageable pageable, int increment) {
		return new PagingNavigationIncrementLink<Void>(id, pageable, increment);
	}

	protected AbstractLink newPagingNavigationLink(String id,
			IPageable pageable, int pageNumber) {
		return new PagingNavigationLink<Void>(id, pageable, pageNumber);
	}

	protected void newNavigation(final IPageable pageable,
			final IPagingLabelProvider labelProvider) {
		String label = "";
		long pageIndex = getPageable().getCurrentPage();
		if (labelProvider != null)
		{
			label = labelProvider.getPageLabel(pageIndex);
			log.info("Sheldon"+label);
		}
		else
		{
			label = String.valueOf(pageIndex + 1);
			log.info("Penny"+label);
		}
		add(new Label("navigation", label));
	}

	private final class TitleAppender extends Behavior {
		private static final long serialVersionUID = 1L;

		private final String resourceKey;

		public TitleAppender(String resourceKey) {
			this.resourceKey = resourceKey;
		}

		@Override
		public void onComponentTag(Component component, ComponentTag tag) {
			tag.put("title", CustomPagingNavigator.this.getString(resourceKey));
		}
	}

}
My Mark Up:

<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Custom PagingNavigator</title>
</head>
<body>
	<wicket:panel>
		 &lt;&lt; | &nbsp; &lt;
			| 
		 |
		 &gt; | &nbsp; &gt;&gt;  
	</wicket:panel>
</body>
</html>

Error Log:
014-06-26 20:15:24,081	<MarkupContainer:ERROR>	Unable to find component with
id 'navigator' in [CustomPagingNavigator [Component id = navigator]]
	Expected: 'navigator:navigator'.
	Found with similar names: 'navigator', navigator:navigation'
2014-06-26 20:15:24,085	<DefaultExceptionMapper:ERROR>	Unexpected error
occurred
Unable to find component with id 'navigator' in [CustomPagingNavigator
[Component id = navigator]]
	Expected: 'navigator:navigator'.
	Found with similar names: 'navigator', navigator:navigation'
 MarkupStream: [markup =
file:/D:/MDW_PROGRAMS/apache-tomcat-7.0.53/webapps/pdflink/WEB-INF/classes/com/mdw/eai/ui/CustomPagingNavigator.html
<wicket:panel>
		 &lt;&lt; | &nbsp; &lt;
			| 
		 |
		 &gt; | &nbsp; &gt;&gt;  
	</wicket:panel>, index = 10, current =  '' (line 0, column 0)]
	at
org.apache.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java:526)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1436)
	at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1555)
	at
org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1530)
	at
org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:689)
	at
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76)
	at
org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy.onComponentTagBody(PanelMarkupSourcingStrategy.java:112)
	at org.apache.wicket.Component.internalRenderComponent(Component.java:2551)
	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1494)
	at org.apache.wicket.Component.internalRender(Component.java:2381)
	at org.apache.wicket.Component.render(Component.java:2309)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390)
	at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1555)
	at org.apache.wicket.Page.onRender(Page.java:887)
	at org.apache.wicket.markup.html.WebPage.onRender(WebPage.java:142)
	at org.apache.wicket.Component.internalRender(Component.java:2381)
	at org.apache.wicket.Component.render(Component.java:2309)
	at org.apache.wicket.Page.renderPage(Page.java:1024)
	at
org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:121)
	at
org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:274)
	at
org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
	at
org.apache.wicket.core.request.handler.RequestSettingRequestHandler.respond(RequestSettingRequestHandler.java:78)
	at
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862)
	at
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
	at
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
	at
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
	at
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
	at
org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
	at
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
	at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
	at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
	at
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)
	at
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)




-----

K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-Pagination-tp4666387.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message