I changed 5 files in package wicket.ajax.markup.html.navigation.paging.
Now, In wicket.examples.ajax.builtin.PageablesPage , I can easily add my IAjaxCallDecorator to navigation link :)
like this:
datacontainer.add(new AjaxPagingNavigator("navigator", listview){
protected IAjaxCallDecorator getLinkAjaxCallDecorator(){
return new AjaxCallDecorator(){
public java.lang.CharSequence decorateOnSuccessScript(java.lang.CharSequence script){
return script + " alert('jump page ok!'); ";
}
public java.lang.CharSequence decorateOnFailureScript(java.lang.CharSequence script){
return script + " alert('jump page failed!'); ";
}
};
}
});
the changelog file shows what I've changed.
Will anyone please review them and submit to the svn ?
And I think there's the same problem with wicket.extensions.markup.html.repeater.data.sort.OrderByBorder Link .
outersky
On 6/9/06, lu dongping <[EMAIL PROTECTED]> wrote:
ok, I'll try it.On 6/9/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:it should probably have a getLinkAjaxCallDecorator() that all links would pull from. can you provide a patch please?
-IgorOn 6/8/06, lu dongping <[EMAIL PROTECTED]> wrote:hi , all
I need to call my _javascript_ after jumping to the next page, how can I do this?
I explored the wicket source, it seemed that there were no easy ways.
The only way I find out is to extend AjaxPagingNavigator and add my own IAjaxCallDecorator to AjaxPagingNavigationBehavior, but then I have to extends many classes including :
AjaxPagingNavigator , AjaxPagingNavigationIncrementLink , AjaxPagingNavigation ... .
to add my decorator the default Ajax Link .
Maybe AjaxPagingNavigator should provide setAjaxCallDecorator () method ?
outersky
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop
/* * $Id: AjaxPagingNavigation.java 5125 2006-03-25 19:42:10Z ivaynberg $ * $Revision: 5125 $ $Date: 2006-03-26 03:42:10 +0800 (Sun, 26 Mar 2006) $ * * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package wicket.ajax.markup.html.navigation.paging;
import wicket.ajax.IAjaxCallDecorator; import wicket.markup.html.navigation.paging.IPageable; import wicket.markup.html.navigation.paging.IPagingLabelProvider; import wicket.markup.html.navigation.paging.PagingNavigationLink; /** * An ajaxified navigation for a PageableListView that holds links to other * pages of the PageableListView. * <p> * Please * * @see wicket.markup.html.navigation.paging.PagingNavigation * * @since 1.2 * * @author Martijn Dashorst */ public class AjaxPagingNavigation extends wicket.markup.html.navigation.paging.PagingNavigation { private static final long serialVersionUID = 1L; private final IAjaxCallDecorator ajaxCallDecorator; /** * Constructor. * * @param id * See Component * @param pageable * The underlying pageable component to navigate */ public AjaxPagingNavigation(final String id, final IPageable pageable) { this(id, pageable, null); } /** * Constructor. * * @param id * See Component * @param pageable * The underlying pageable component to navigate * @param labelProvider * The label provider for the text that the links should be * displaying. */ public AjaxPagingNavigation(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { this(id, pageable, labelProvider,null); } public AjaxPagingNavigation(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider, final IAjaxCallDecorator ajaxCallDecorator) { super(id, pageable, labelProvider); this.ajaxCallDecorator = ajaxCallDecorator; } /** * Factory method for creating ajaxian page number links. * * @param id * link id * @param pageable * the pageable * @param pageIndex * the index the link points to * @return the ajaxified page number link. */ protected PagingNavigationLink newPagingNavigationLink(String id, IPageable pageable, int pageIndex) { return new AjaxPagingNavigationLink(id, pageable, pageIndex,ajaxCallDecorator); } }
/* * $Id: AjaxPagingNavigationBehavior.java 4635 2006-02-25 16:24:23 -0800 (Sat, * 25 Feb 2006) dashorst $ $Revision: 5205 $ $Date: 2006-02-25 16:24:23 -0800 * (Sat, 25 Feb 2006) $ * * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package wicket.ajax.markup.html.navigation.paging; import wicket.Component; import wicket.MarkupContainer; import wicket.ajax.AjaxEventBehavior; import wicket.ajax.AjaxRequestTarget; import wicket.ajax.IAjaxCallDecorator; import wicket.ajax.calldecorator.CancelEventIfNoAjaxDecorator; import wicket.ajax.markup.html.IAjaxLink; import wicket.markup.html.navigation.paging.IPageable; /** * Ajax behavior for the paging navigation links. This behavior can only have * one parent: the link it is attached to. * * @since 1.2 * * @author Martijn Dashorst */ public class AjaxPagingNavigationBehavior extends AjaxEventBehavior { /** For serialization. */ private static final long serialVersionUID = 1L; /** * The ajaxian link that should recieve the event. */ private final IAjaxLink owner; /** * The pageable component to update. */ private final IPageable pageable; private final IAjaxCallDecorator ajaxCallDecorator; /** * Attaches the navigation behavior to the owner link and drives the * pageable component. The behavior is attached to the markup event. * * @param owner * the owner ajax link * @param pageable * the pageable to update * @param event * the javascript event to bind to (e.g. onclick) */ public AjaxPagingNavigationBehavior(IAjaxLink owner, IPageable pageable, String event) { this(owner, pageable, event, null); } /** * Attaches the navigation behavior to the owner link and drives the * pageable component. The behavior is attached to the markup event. * * @param owner * the owner ajax link * @param pageable * the pageable to update * @param event * the javascript event to bind to (e.g. onclick) * @param ajaxCallDecorator * the IAjaxCallDecorator for the link */ public AjaxPagingNavigationBehavior(IAjaxLink owner, IPageable pageable, String event, final IAjaxCallDecorator ajaxCallDecorator) { super(event); this.owner = owner; this.pageable = pageable; this.ajaxCallDecorator = ajaxCallDecorator; } /** * The ajax event handler. This will execute the event, and update the * following components, when present: the navigator the owner link is part * of, or when the link is a stand alone component, the link itself. Also * the pageable's parent markup container is updated, so its contents can be * replaced with the newly generated pageable. * * @see wicket.ajax.AjaxEventBehavior#onEvent(wicket.ajax.AjaxRequestTarget) */ protected void onEvent(AjaxRequestTarget target) { // handle the event owner.onClick(target); // update the container (parent) of the pageable, this assumes that // the pageable is a component, and that it is a child of a web // markup container. If no parent is found, the whole page will be // updated. Component container = ((Component)pageable).findParent(MarkupContainer.class); target.addComponent(container); // find the PagingNavigator parent of this link Component navigator = (AjaxPagingNavigator)((Component)owner) .findParent(AjaxPagingNavigator.class); if (navigator == null) { // this is an ugly cast, but we do not have IComponent to properly // mixin IAjaxLink navigator = (Component)owner; } if (navigator != null) { if (!(container instanceof MarkupContainer && ((MarkupContainer)container) .contains(navigator, true))) { target.addComponent(navigator); } } } /** * * @see wicket.ajax.AbstractDefaultAjaxBehavior#getAjaxCallDecorator() */ protected IAjaxCallDecorator getAjaxCallDecorator() { return new CancelEventIfNoAjaxDecorator(ajaxCallDecorator); } }
/* * $Id: PagingNavigationIncrementLink.java,v 1.3 2005/02/17 06:15:27 * jonathanlocke Exp $ $Revision: 5125 $ $Date: 2006-02-25 16:24:23 -0800 (Sat, * 25 Feb 2006) $ * * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package wicket.ajax.markup.html.navigation.paging; import wicket.ajax.AjaxRequestTarget; import wicket.ajax.IAjaxCallDecorator; import wicket.ajax.markup.html.IAjaxLink; import wicket.markup.html.navigation.paging.IPageable; import wicket.markup.html.navigation.paging.PagingNavigationIncrementLink; /** * An incremental Ajaxian link to a page of a PageableListView. Assuming your * list view navigation looks like * * <pre> * * [first / << / <] 1 | 2 | 3 [> / >> /last] * * </pre> * * <p> * and "<" meaning the previous and "<<" goto the "current page - 5", * than it is this kind of incremental page links which can easily be created. * * This link will update the pageable and itself or the navigator the link is * part of using Ajax techniques, or perform a full refresh when ajax is not * available. * * @since 1.2 * * @author Martijn Dashorst */ public class AjaxPagingNavigationIncrementLink extends PagingNavigationIncrementLink implements IAjaxLink { private static final long serialVersionUID = 1L; /** * Constructor. * * @param id * See Component * @param pageable * The pageable component the page links are referring to * @param increment * increment by */ public AjaxPagingNavigationIncrementLink(final String id, final IPageable pageable, final int increment) { this(id,pageable,increment,null); } /** * Constructor. * * @param id * See Component * @param pageable * The pageable component the page links are referring to * @param increment * increment by * @param ajaxCallDecorator * the IAjaxCallDecorator for the link */ public AjaxPagingNavigationIncrementLink(final String id, final IPageable pageable, final int increment, final IAjaxCallDecorator ajaxCallDecorator) { super(id, pageable, increment); add(new AjaxPagingNavigationBehavior(this, pageable, "onclick",ajaxCallDecorator)); setOutputMarkupId(true); } /** * Returns the javascript event handler for this component. This function is * used to decorate the generated javascript handler. * <p> * NOTE: It is recommended that you only prepend additional javascript to * the default handler because the default handler uses the return func() * format so any appended javascript will not be evaluated by default. * * @param defaultHandler * default javascript event handler generated by this link * @return javascript event handler for this link */ protected String getEventHandler(String defaultHandler) { return defaultHandler; } /** * Fallback event listener, will redisplay the current page. * * @see wicket.markup.html.link.Link#onClick() */ public void onClick() { onClick(null); // We do not need to redirect setRedirect(false); // Return the the current page. setResponsePage(getPage()); } /** * Performs the actual action of this component, performing a non-ajax * fallback when there was no AjaxRequestTarget available. * * @param target * the request target, when <code>null</code>, a full page * refresh will be generated */ public void onClick(AjaxRequestTarget target) { // Tell the PageableListView which page to print next pageable.setCurrentPage(getPageNumber()); } }
/* * $Id: AjaxPagingNavigationLink.java 5125 2006-03-25 19:42:10Z ivaynberg $ * $Revision: 5125 $ $Date: 2006-03-26 03:42:10 +0800 (Sun, 26 Mar 2006) $ * * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package wicket.ajax.markup.html.navigation.paging; import wicket.ajax.AjaxRequestTarget; import wicket.ajax.IAjaxCallDecorator; import wicket.ajax.markup.html.IAjaxLink; import wicket.markup.html.navigation.paging.IPageable; import wicket.markup.html.navigation.paging.PagingNavigationLink; /** * An Ajax version of a link to a page of a PageableListView. * * @since 1.2 * * @author Martijn Dashorst */ public class AjaxPagingNavigationLink extends PagingNavigationLink implements IAjaxLink { private static final long serialVersionUID = 1L; /** * Constructor. * * @param id * See Component * @param pageable * The pageable component for this page link * @param pageNumber * The page number in the PageableListView that this link links * to. Negative pageNumbers are relative to the end of the list. */ public AjaxPagingNavigationLink(final String id, final IPageable pageable, final int pageNumber) { this(id,pageable,pageNumber,null); } /** * Constructor. * * @param id * See Component * @param pageable * The pageable component for this page link * @param pageNumber * The page number in the PageableListView that this link links * to. Negative pageNumbers are relative to the end of the list. * @param ajaxCallDecorator * the IAjaxCallDecorator for the link */ public AjaxPagingNavigationLink(final String id, final IPageable pageable, final int pageNumber, final IAjaxCallDecorator ajaxCallDecorator) { super(id, pageable, pageNumber); add(new AjaxPagingNavigationBehavior(this, pageable, "onclick",ajaxCallDecorator)); setOutputMarkupId(true); } /** * Fallback event listener, will redisplay the current page. * * @see wicket.markup.html.link.Link#onClick() */ public void onClick() { onClick(null); // We do not need to redirect setRedirect(false); // Return the the current page. setResponsePage(getPage()); } /** * Performs the actual action of this component, performing a non-ajax * fallback when there was no AjaxRequestTarget available. * * @param target * the request target, when <code>null</code>, a full page * refresh will be generated */ public void onClick(AjaxRequestTarget target) { pageable.setCurrentPage(getPageNumber()); } }
/* * $Id: AjaxPagingNavigator.java 5125 2006-03-25 19:42:10Z ivaynberg $ $Revision: * 4635 $ $Date: 2006-03-26 03:42:10 +0800 (Sun, 26 Mar 2006) $ * * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package wicket.ajax.markup.html.navigation.paging; import wicket.ajax.IAjaxCallDecorator; import wicket.markup.html.link.Link; import wicket.markup.html.navigation.paging.IPageable; import wicket.markup.html.navigation.paging.IPagingLabelProvider; import wicket.markup.html.navigation.paging.PagingNavigation; import wicket.markup.html.navigation.paging.PagingNavigator; /** * A Wicket panel component to draw and maintain a complete page navigator, * meant to be easily added to any PageableListView. A navigation which contains * links to the first and last page, the current page +- some increment and * which supports paged navigation bars (@see * PageableListViewNavigationWithMargin). * <p> * <strong>NOTE</strong> To use the, you <i>have</i> to put your listview in a * webmarkupcontainer, otherwise it is not possible to update the contents of * the listview using Ajax. * * @since 1.2 * * @author Martijn Dashorst */ public class AjaxPagingNavigator extends PagingNavigator { private static final long serialVersionUID = 1L; /** * Constructor. * * @param id * See Component * @param pageable * The pageable component the page links are referring to. */ public AjaxPagingNavigator(final String id, final IPageable pageable) { this(id, pageable, null); } /** * Constructor. * * @param id * See Component * @param pageable * The pageable component the page links are referring to. * @param labelProvider * The label provider for the link text. */ public AjaxPagingNavigator(final String id, final IPageable pageable, final IPagingLabelProvider labelProvider) { super(id, pageable, labelProvider); setOutputMarkupId(true); } /** * Create a new increment link. May be subclassed to make use of specialized * links, e.g. Ajaxian links. * * @param id * the link id * @param pageable * the pageable to control * @param increment * the increment * @return the increment link */ protected Link newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) { return new AjaxPagingNavigationIncrementLink(id, pageable, increment,getLinkAjaxCallDecorator()); } /** * Create a new pagenumber link. May be subclassed to make use of * specialized links, e.g. Ajaxian links. * * @param id * the link id * @param pageable * the pageable to control * @param pageNumber * the page to jump to * @return the pagenumber link */ protected Link newPagingNavigationLink(String id, IPageable pageable, int pageNumber) { return new AjaxPagingNavigationLink(id, pageable, pageNumber,getLinkAjaxCallDecorator()); } /** * Create a new PagingNavigation. May be subclassed to make us of * specialized PagingNavigation. * * @param pageable * the pageable component * @param labelProvider * The label provider for the link text. * @return the navigation object */ protected PagingNavigation newNavigation(final IPageable pageable, final IPagingLabelProvider labelProvider) { return new AjaxPagingNavigation("navigation", pageable, labelProvider,getLinkAjaxCallDecorator()); } /** * Get the AjaxCallDecorator for every navigation link. */ protected IAjaxCallDecorator getLinkAjaxCallDecorator() { return null; } }
changelog
Description: Binary data
_______________________________________________ Wicket-develop mailing list Wicket-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-develop