01: /*
02: * $Id$ $Revision$ $Date$
03: *
04: * ==============================================================================
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License. You may obtain a copy of
07: * the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package wicket.extensions.ajax.markup.html.repeater.data.table;
18:
19: import wicket.ajax.AjaxRequestTarget;
20: import wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
21: import wicket.extensions.markup.html.repeater.data.table.DataTable;
22: import wicket.extensions.markup.html.repeater.data.table.NavigationToolbar;
23: import wicket.markup.html.navigation.paging.PagingNavigator;
24:
25: /**
26: * Toolbar that displays (Ajax) links used to navigate the pages of the
27: * datatable as well as a message about which rows are being displayed and their
28: * total number in the data table.
29: *
30: * @author Igor Vaynberg (ivaynberg)
31: * @author Martijn Dashorst (dashorst)
32: * @since 1.2.1
33: */
34: public class AjaxNavigationToolbar extends NavigationToolbar {
35: private static final long serialVersionUID = 1L;
36:
37: /**
38: * Constructor.
39: *
40: * @param table
41: * data table this toolbar will be attached to
42: */
43: public AjaxNavigationToolbar(final DataTable table) {
44: super (table);
45: }
46:
47: /**
48: * Factory method used to create the paging navigator that will be used by
49: * the datatable.
50: *
51: * @param navigatorId
52: * component id the navigator should be created with
53: * @param table
54: * dataview used by datatable
55: * @return paging navigator that will be used to navigate the data table
56: */
57: protected PagingNavigator newPagingNavigator(String navigatorId,
58: final DataTable table) {
59: return new AjaxPagingNavigator(navigatorId, table) {
60: private static final long serialVersionUID = 1L;
61:
62: /**
63: * Implement our own ajax event handling in order to update the
64: * datatable itself, as the default implementation doesn't support
65: * DataViews.
66: *
67: * @see AjaxPagingNavigator#onAjaxEvent(AjaxRequestTarget)
68: */
69: protected void onAjaxEvent(AjaxRequestTarget target) {
70: target.addComponent(table);
71: }
72: };
73: }
74: }
|