You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sumit Raja <su...@gmail.com> on 2010/02/11 01:15:01 UTC

AjaxPagingNavigator with Form Submit

Hi,

I have a DataView that has a Check for each Item. I would like to be able to remember whether an item was checked or not across page navigation actions as this is not happening currently. 

I read an old thread that indicated that changing the navigational links to be Ajax submit buttons will allow the form the be submitted. There does not seem to be an easy way of doing this without duplicating a lot of code from the existing ajax navigator. Has anyone done this before?

I did try a simple test of adding AjaxFormSubmitBehaviour on the mouseover event to see if the form gets submitted but this does not happen. Code is below.

Any help much appreciated,

Thanks

Sumit


dataContainer = new Form<Collection<Asset>>("form");

.
.
.

AjaxPagingNavigator pager = new AjaxPagingNavigator("navigator", dataView) {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onAjaxEvent(AjaxRequestTarget target) {
                target.addComponent(dataContainer);
            }

            @Override
            protected Link<?> newPagingNavigationLink(String id, IPageable pageable, int pageNumber) {
                Link<?> superLink = super.newPagingNavigationLink(id, pageable, pageNumber);
                superLink.add(new AjaxFormSubmitBehavior(dataContainer, "onmouseover") {

                    private static final long serialVersionUID = 1L;
                    
                    @Override
                    protected void onSubmit(AjaxRequestTarget target) {
                        System.out.println("onSubmit");
                    }

                    @Override
                    protected void onError(AjaxRequestTarget target) {
                       
                    }

                });
                return superLink;
            }

            @Override
            protected Link<?> newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) {
                Link<?> superLink = super.newPagingNavigationIncrementLink(id, pageable, increment);
                superLink.add(new AjaxFormSubmitBehavior(dataContainer, "onmouseover") {

                    private static final long serialVersionUID = 1L;
                    
                    @Override
                    protected void onSubmit(AjaxRequestTarget target) {
                        
                    }

                    @Override
                    protected void onError(AjaxRequestTarget target) {
                       
                    }

                });
                return superLink;
            }
            
            
        };