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.attributes.AjaxRequestAttributes; 021import org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder; 022import org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortStateLocator; 023import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; 024import org.apache.wicket.extensions.markup.html.repeater.data.table.HeadersToolbar; 025import org.apache.wicket.markup.html.WebMarkupContainer; 026 027 028/** 029 * Ajaxified {@link HeadersToolbar} 030 * 031 * @param <S> 032 * the type of the sort property 033 * @see HeadersToolbar 034 * 035 * @author ivaynberg 036 * 037 */ 038public class AjaxFallbackHeadersToolbar<S> extends HeadersToolbar<S> 039{ 040 private static final long serialVersionUID = 1L; 041 042 /** 043 * Constructor 044 * 045 * @param table 046 * @param stateLocator 047 */ 048 public AjaxFallbackHeadersToolbar(final DataTable<?, S> table, final ISortStateLocator<S> stateLocator) 049 { 050 super(table, stateLocator); 051 table.setOutputMarkupId(true); 052 } 053 054 /** 055 * {@inheritDoc} 056 */ 057 @Override 058 protected WebMarkupContainer newSortableHeader(final String borderId, final S property, 059 final ISortStateLocator<S> locator) 060 { 061 return new AjaxFallbackOrderByBorder<S>(borderId, property, locator) 062 { 063 private static final long serialVersionUID = 1L; 064 065 @Override 066 protected void updateAjaxAttributes(AjaxRequestAttributes attributes) 067 { 068 AjaxFallbackHeadersToolbar.this.updateAjaxAttributes(attributes); 069 } 070 071 @Override 072 protected void onAjaxClick(final AjaxRequestTarget target) 073 { 074 target.add(getTable()); 075 } 076 077 @Override 078 protected void onSortChanged() 079 { 080 super.onSortChanged(); 081 getTable().setCurrentPage(0); 082 } 083 }; 084 } 085 086 protected void updateAjaxAttributes(AjaxRequestAttributes attributes) 087 { 088 } 089}