You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by K <ko...@gmail.com> on 2014/06/26 16:55:21 UTC
Custom Pagination
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>
<< | <
|
|
> | >>
</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>
<< | <
|
|
> | >>
</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
Re: Custom Pagination
Posted by Paul Bors <pa...@bors.ws>.
You're half way home.
You extended PagingNavigator but forgot to read its code.
See line 150 of PagingNavigator or better said the newNavigation() method:
/**
* Create a new PagingNavigation. May be subclassed to make us of
specialized PagingNavigation.
*
* @param id
* The id of the navigation component
* @param pageable
* the pageable component
* @param labelProvider
* The label provider for the link text.
* @return the navigation object
*/
protected PagingNavigation newNavigation(final String id, final
IPageable pageable,
final IPagingLabelProvider labelProvider)
{
return new PagingNavigation(id, pageable, labelProvider);
}
In your class, override that factory method to return the type of
PagingNavigation you want.
Also, get more familiar with that component's code. Read and understand how
those classes are related to each other:
https://github.com/apache/wicket/tree/442932d4e4c5cc27940bc2ef956cb24c1ba54df0/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging
On Fri, Jun 27, 2014 at 6:44 AM, K <ko...@gmail.com> wrote:
> Hey sven
>
> thanks for the reply i have resolve the issue
>
> now i have been trying to trying to implement something like
>
> << < (textbox) of (totalnumberofpages) > >>
>
> any suggestions on this
>
>
> -----
>
> K
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Custom-Pagination-tp4666387p4666397.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
>
>
Re: Custom Pagination
Posted by K <ko...@gmail.com>.
Hey sven
thanks for the reply i have resolve the issue
now i have been trying to trying to implement something like
<< < (textbox) of (totalnumberofpages) > >>
any suggestions on this
-----
K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-Pagination-tp4666387p4666397.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
Re: Custom Pagination
Posted by Sven Meier <sv...@meiers.net>.
Hi,
your markup has wicket:id="navigator", but I don't see this id in your
Java code.
Sven
On 06/26/2014 05:04 PM, K wrote:
> 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>
> <an wicket:id="first"><< |
> <an wicket:id="prev">< |
> <spa wicket:id="navigator">
> <spa wicket:id="page1"></spa>
> <spa wicket:id="navigation"></spa>
> <spa wicket:id="of"></spa>
> <spa wicket:id="total"></spa> |</spa>
> <an wicket:id="next">> |
> <an wicket:id="last">>>
> </wicket:panel>
> </body>
> </html>
>
> Note that i changed* newNavigation()* method...
>
> Any help is much appreciated...Thanks.
>
>
> -----
>
> K
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-Pagination-tp4666387p4666389.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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Custom Pagination
Posted by K <ko...@gmail.com>.
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>
<an wicket:id="first"><< |
<an wicket:id="prev">< |
<spa wicket:id="navigator">
<spa wicket:id="page1"></spa>
<spa wicket:id="navigation"></spa>
<spa wicket:id="of"></spa>
<spa wicket:id="total"></spa> |</spa>
<an wicket:id="next">> |
<an wicket:id="last">>>
</wicket:panel>
</body>
</html>
Note that i changed* newNavigation()* method...
Any help is much appreciated...Thanks.
-----
K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-Pagination-tp4666387p4666389.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
Re: Custom Pagination
Posted by Sven Meier <sv...@meiers.net>.
Hi,
your markup didn't make it - do you have wicket:id="navigator" in it?
Sven
On 06/26/2014 04:55 PM, K wrote:
> 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>
> << | <
> |
> |
> > | >>
> </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>
> << | <
> |
> |
> > | >>
> </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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org