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;
018
019import org.apache.wicket.ajax.IAjaxIndicatorAware;
020import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
021import org.apache.wicket.model.IModel;
022
023/**
024 * A variant of the {@link AjaxFallbackLink} that displays a busy indicator while the ajax request
025 * is in progress.
026 * 
027 * @since 1.2
028 * 
029 * @author Igor Vaynberg (ivaynberg)
030 * @param <T>
031 *            type of model
032 * 
033 */
034public abstract class IndicatingAjaxFallbackLink<T> extends AjaxFallbackLink<T>
035        implements
036                IAjaxIndicatorAware
037{
038        private static final long serialVersionUID = 1L;
039
040        private final AjaxIndicatorAppender indicatorAppender = new AjaxIndicatorAppender();
041
042        /**
043         * Constructor
044         * 
045         * @param id
046         */
047        public IndicatingAjaxFallbackLink(final String id)
048        {
049                this(id, null);
050        }
051
052        /**
053         * Constructor
054         * 
055         * @param id
056         * @param model
057         */
058        public IndicatingAjaxFallbackLink(final String id, final IModel<T> model)
059        {
060                super(id, model);
061                add(indicatorAppender);
062        }
063
064        @Override
065        public String getAjaxIndicatorMarkupId()
066        {
067                return indicatorAppender.getMarkupId();
068        }
069
070}