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.sort; 018 019import org.apache.wicket.ajax.AjaxRequestTarget; 020import org.apache.wicket.ajax.attributes.AjaxRequestAttributes; 021import org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortStateLocator; 022import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder; 023import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByLink; 024 025 026/** 027 * Ajaxified version of {@link OrderByBorder} 028 * 029 * @param <S> 030 * the type of the sort property 031 * @see OrderByBorder 032 * 033 * @since 1.2.1 034 * 035 * @author Igor Vaynberg (ivaynberg) 036 * 037 */ 038public abstract class AjaxFallbackOrderByBorder<S> extends OrderByBorder<S> 039{ 040 private static final long serialVersionUID = 1L; 041 042 /** 043 * Constructor 044 * 045 * @param id 046 * @param sortProperty 047 * @param stateLocator 048 */ 049 public AjaxFallbackOrderByBorder(final String id, final S sortProperty, 050 final ISortStateLocator<S> stateLocator) 051 { 052 super(id, sortProperty, stateLocator); 053 } 054 055 @Override 056 protected OrderByLink<S> newOrderByLink(String id, S property, ISortStateLocator<S> stateLocator) 057 { 058 return new AjaxOrderByLink<S>("orderByLink", property, stateLocator) 059 { 060 private static final long serialVersionUID = 1L; 061 062 @Override 063 protected void updateAjaxAttributes(AjaxRequestAttributes attributes) 064 { 065 AjaxFallbackOrderByBorder.this.updateAjaxAttributes(attributes); 066 } 067 068 @Override 069 protected void onSortChanged() 070 { 071 AjaxFallbackOrderByBorder.this.onSortChanged(); 072 } 073 074 @Override 075 public void onClick(final AjaxRequestTarget target) 076 { 077 AjaxFallbackOrderByBorder.this.onAjaxClick(target); 078 079 } 080 }; 081 } 082 083 protected void updateAjaxAttributes(AjaxRequestAttributes attributes) 084 { 085 } 086 087 /** 088 * This method is a hook for subclasses to perform an action after sort has changed 089 */ 090 @Override 091 protected void onSortChanged() 092 { 093 // noop 094 } 095 096 protected abstract void onAjaxClick(AjaxRequestTarget target); 097}