Re: PagingNavigator refactoring request
Hi Igor, your patch is working great. As initialisation occurs in onBeforeRender() now, I can even use getParent().getClass() without having an additional pageClass constructor parameter. So, please apply the patch :) Thanks again for your time! igor.vaynberg wrote: see if this patch helps, and if it works and doesnt break anything that you can see i will apply it... -igor Index: C:/dev/src/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.java === --- C:/dev/src/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.java (revision 611946) +++ C:/dev/src/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.java (working copy) @@ -32,8 +32,11 @@ private static final long serialVersionUID = 1L; /** The navigation bar to be printed, e.g. 1 | 2 | 3 etc. */ - private final PagingNavigation pagingNavigation; + private PagingNavigation pagingNavigation; + private final IPageable pageable; + private final IPagingLabelProvider labelProvider; + /** * Constructor. * @@ -58,20 +61,28 @@ *The label provider for the link text. */ public PagingNavigator(final String id, final IPageable pageable, - final IPagingLabelProvider labelProvider) + final IPagingLabelProvider labelProvider) { super(id); + this.pageable = pageable; + this.labelProvider = labelProvider; + } + protected void onBeforeRender() + { + if (!hasBeenRendered()) + { + // Get the navigation bar and add it to the hierarchy + pagingNavigation = newNavigation(pageable, labelProvider); + add(pagingNavigation); - // Get the navigation bar and add it to the hierarchy - this.pagingNavigation = newNavigation(pageable, labelProvider); - add(pagingNavigation); - - // Add additional page links - add(newPagingNavigationLink(first, pageable, 0)); - add(newPagingNavigationIncrementLink(prev, pageable, -1)); - add(newPagingNavigationIncrementLink(next, pageable, 1)); - add(newPagingNavigationLink(last, pageable, -1)); + // Add additional page links + add(newPagingNavigationLink(first, pageable, 0)); + add(newPagingNavigationIncrementLink(prev, pageable, -1)); + add(newPagingNavigationIncrementLink(next, pageable, 1)); + add(newPagingNavigationLink(last, pageable, -1)); + } + super.onBeforeRender(); } /** @@ -118,7 +129,7 @@ * @return the navigation object */ protected PagingNavigation newNavigation(final IPageable pageable, - final IPagingLabelProvider labelProvider) + final IPagingLabelProvider labelProvider) { return new PagingNavigation(navigation, pageable, labelProvider); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14839357.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PagingNavigator refactoring request
Not such a good idea, huh? :) behlma wrote: Hi guys, would it be possible to change PagingNavigator's constructor from public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); // Get the navigation bar and add it to the hierarchy this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); // Add additional page links add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); } /** to public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); initNavigator(pageable, labelProvider); } protected initNavigator(pageable, provider) { this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); } I'm asking because I subclassed PagingNavigator and I have additional constructor parameters I want to pass to the constructor before invoking initNavigator. Thanks for your time! -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14797267.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PagingNavigator refactoring request
what exactly is the usecase? -igor On Jan 14, 2008 12:49 AM, behlma [EMAIL PROTECTED] wrote: Not such a good idea, huh? :) behlma wrote: Hi guys, would it be possible to change PagingNavigator's constructor from public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); // Get the navigation bar and add it to the hierarchy this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); // Add additional page links add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); } /** to public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); initNavigator(pageable, labelProvider); } protected initNavigator(pageable, provider) { this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); } I'm asking because I subclassed PagingNavigator and I have additional constructor parameters I want to pass to the constructor before invoking initNavigator. Thanks for your time! -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14797267.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PagingNavigator refactoring request
would you just override all the newPaging* factory methods? perhaps if you paste your code and what you cannot do i might help you more, right now i just dont see it :| -igor On Jan 14, 2008 12:03 PM, behlma [EMAIL PROTECTED] wrote: Hi Igor, I created a BookmarkablePagingNavigator component. Its constructor takes a PageParameter object, that needs - of course - to be set *before*: add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); as they are all bookmarkable links. igor.vaynberg wrote: what exactly is the usecase? -igor On Jan 14, 2008 12:49 AM, behlma [EMAIL PROTECTED] wrote: Not such a good idea, huh? :) behlma wrote: Hi guys, would it be possible to change PagingNavigator's constructor from public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); // Get the navigation bar and add it to the hierarchy this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); // Add additional page links add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); } /** to public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); initNavigator(pageable, labelProvider); } protected initNavigator(pageable, provider) { this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); } I'm asking because I subclassed PagingNavigator and I have additional constructor parameters I want to pass to the constructor before invoking initNavigator. Thanks for your time! -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14797267.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14812182.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PagingNavigator refactoring request
Hi Igor, I created a BookmarkablePagingNavigator component. Its constructor takes a PageParameter object, that needs - of course - to be set *before*: add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); as they are all bookmarkable links. igor.vaynberg wrote: what exactly is the usecase? -igor On Jan 14, 2008 12:49 AM, behlma [EMAIL PROTECTED] wrote: Not such a good idea, huh? :) behlma wrote: Hi guys, would it be possible to change PagingNavigator's constructor from public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); // Get the navigation bar and add it to the hierarchy this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); // Add additional page links add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); } /** to public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); initNavigator(pageable, labelProvider); } protected initNavigator(pageable, provider) { this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); } I'm asking because I subclassed PagingNavigator and I have additional constructor parameters I want to pass to the constructor before invoking initNavigator. Thanks for your time! -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14797267.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14812182.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PagingNavigator refactoring request
Hi Igor, I created a BookmarkablePagingNavigationIncrementLink / BookmarkablePagingNavigationLink as well as a BookmarkablePagingNavigation (those three simply being the bookmarkable version of the ones already existing in wicket-core). The overridden methods therefore simply look like: protected Link newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) { return new BookmarkablePagingNavigationIncrementLink(id, this.clazz, pageable, this.params, increment); } protected Link newPagingNavigationLink(String id, IPageable pageable, int pageNumber) { return new BookmarkablePagingNavigationLink(id, this.clazz, pageable, this.params, pageNumber); } etc... As the Bookmarkable links need a pageClass and pageParameters, I wanted to pass them to my navigator's constructor. Problem being, if you extend from Wicket's PagingNavigator, you cannot set pageParams and pageClass before newPagingNavigationLink() etc.. gets called. Finally, the gist :) I simply didn't wanna duplicate PagingNavigator.java/.html if the only thing I do is this.params = params; this.clazz = clazz; before the PaginationLinks are called. Puh, Thanks again for reading :) igor.vaynberg wrote: would you just override all the newPaging* factory methods? perhaps if you paste your code and what you cannot do i might help you more, right now i just dont see it :| -igor On Jan 14, 2008 12:03 PM, behlma [EMAIL PROTECTED] wrote: Hi Igor, I created a BookmarkablePagingNavigator component. Its constructor takes a PageParameter object, that needs - of course - to be set *before*: add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); as they are all bookmarkable links. igor.vaynberg wrote: what exactly is the usecase? -igor On Jan 14, 2008 12:49 AM, behlma [EMAIL PROTECTED] wrote: Not such a good idea, huh? :) behlma wrote: Hi guys, would it be possible to change PagingNavigator's constructor from public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); // Get the navigation bar and add it to the hierarchy this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); // Add additional page links add(newPagingNavigationLink(first, pageable, 0)); add(newPagingNavigationIncrementLink(prev, pageable, -1)); add(newPagingNavigationIncrementLink(next, pageable, 1)); add(newPagingNavigationLink(last, pageable, -1)); } /** to public PagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id); initNavigator(pageable, labelProvider); } protected initNavigator(pageable, provider) { this.pagingNavigation = newNavigation(pageable, labelProvider); add(pagingNavigation); } I'm asking because I subclassed PagingNavigator and I have additional constructor parameters I want to pass to the constructor before invoking initNavigator. Thanks for your time! -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14797267.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14812182.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/PagingNavigator-refactoring-request-tp14783646p14817983.html Sent from the Wicket - User mailing list archive at Nabble.com.