001: /*
002: * $Id$ $Revision$ $Date$
003: *
004: * ==============================================================================
005: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
006: * use this file except in compliance with the License. You may obtain a copy of
007: * 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, WITHOUT
013: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014: * License for the specific language governing permissions and limitations under
015: * the License.
016: */
017: package wicket.extensions.ajax.markup.html.repeater.data.sort;
018:
019: import wicket.ajax.AjaxEventBehavior;
020: import wicket.ajax.AjaxRequestTarget;
021: import wicket.ajax.IAjaxCallDecorator;
022: import wicket.ajax.calldecorator.CancelEventIfNoAjaxDecorator;
023: import wicket.extensions.markup.html.repeater.data.sort.ISortStateLocator;
024: import wicket.extensions.markup.html.repeater.data.sort.OrderByLink;
025:
026: /**
027: * Ajaxified {@link OrderByLink}
028: *
029: * @see OrderByLink
030: *
031: * @since 1.2.1
032: *
033: * @author Igor Vaynberg (ivaynberg)
034: *
035: */
036: public abstract class AjaxFallbackOrderByLink extends OrderByLink {
037: /**
038: *
039: */
040: private static final long serialVersionUID = 1L;
041:
042: /**
043: * Constructor
044: *
045: * @param id
046: * @param property
047: * @param stateLocator
048: * @param cssProvider
049: */
050: public AjaxFallbackOrderByLink(String id, String property,
051: ISortStateLocator stateLocator, ICssProvider cssProvider) {
052: this (id, property, stateLocator, cssProvider, null);
053: }
054:
055: /**
056: * Constructor
057: *
058: * @param id
059: * @param property
060: * @param stateLocator
061: */
062: public AjaxFallbackOrderByLink(String id, String property,
063: ISortStateLocator stateLocator) {
064: this (id, property, stateLocator, DefaultCssProvider
065: .getInstance(), null);
066: }
067:
068: /**
069: * Constructor
070: *
071: * @param id
072: * @param property
073: * @param stateLocator
074: * @param decorator
075: */
076: public AjaxFallbackOrderByLink(String id, String property,
077: ISortStateLocator stateLocator,
078: final IAjaxCallDecorator decorator) {
079: this (id, property, stateLocator, DefaultCssProvider
080: .getInstance(), decorator);
081: }
082:
083: /**
084: * Constructor
085: *
086: * @param id
087: * @param property
088: * @param stateLocator
089: * @param cssProvider
090: * @param decorator
091: */
092: public AjaxFallbackOrderByLink(String id, String property,
093: ISortStateLocator stateLocator, ICssProvider cssProvider,
094: final IAjaxCallDecorator decorator) {
095: super (id, property, stateLocator, cssProvider);
096:
097: add(new AjaxEventBehavior("onclick") {
098: private static final long serialVersionUID = 1L;
099:
100: protected void onEvent(AjaxRequestTarget target) {
101: onClick();
102: onAjaxClick(target);
103: }
104:
105: protected IAjaxCallDecorator getAjaxCallDecorator() {
106: return new CancelEventIfNoAjaxDecorator(decorator);
107: }
108:
109: });
110:
111: }
112:
113: /**
114: * Callback method when an ajax click occurs. All the behavior of changing
115: * the sort, etc is already performed bfore this is called so this method
116: * should primarily be used to configure the target.
117: *
118: * @param target
119: */
120: protected abstract void onAjaxClick(AjaxRequestTarget target);
121:
122: }
|