001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.extensions.ajax.markup.html.repeater.data.table; 018 019import org.apache.wicket.ajax.AjaxRequestTarget; 020import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator; 021import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; 022import org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar; 023import org.apache.wicket.markup.html.navigation.paging.PagingNavigator; 024 025 026/** 027 * Toolbar that displays (Ajax) links used to navigate the pages of the datatable as well as a 028 * message about which rows are being displayed and their total number in the data table. 029 * 030 * @author Igor Vaynberg (ivaynberg) 031 * @author Martijn Dashorst (dashorst) 032 * @since 1.2.1 033 */ 034public class AjaxNavigationToolbar extends NavigationToolbar 035{ 036 private static final long serialVersionUID = 1L; 037 038 /** 039 * Constructor. 040 * 041 * @param table 042 * data table this toolbar will be attached to 043 */ 044 public AjaxNavigationToolbar(final DataTable<?, ?> table) 045 { 046 super(table); 047 } 048 049 /** 050 * Factory method used to create the paging navigator that will be used by the datatable. 051 * 052 * @param navigatorId 053 * component id the navigator should be created with 054 * @param table 055 * dataview used by datatable 056 * @return paging navigator that will be used to navigate the data table 057 */ 058 @Override 059 protected PagingNavigator newPagingNavigator(final String navigatorId, final DataTable<?, ?> table) 060 { 061 return new AjaxPagingNavigator(navigatorId, table) 062 { 063 private static final long serialVersionUID = 1L; 064 065 /** 066 * Implement our own ajax event handling in order to update the datatable itself, as the 067 * default implementation doesn't support DataViews. 068 * 069 * @see AjaxPagingNavigator#onAjaxEvent(org.apache.wicket.ajax.AjaxRequestTarget) 070 */ 071 @Override 072 protected void onAjaxEvent(final AjaxRequestTarget target) 073 { 074 target.add(table); 075 } 076 }; 077 } 078}