/*
 * $Id: SimpleHrefComponent.java,v 1.1 2004/10/31 09:34:45 jdonnerstag Exp $
 * $Revision: 1.1 $
 * $Date: 2004/10/31 09:34:45 $
 *
 * ====================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.voicetribe.wicket.markup.html.link;

import com.voicetribe.wicket.RequestCycle;
import com.voicetribe.wicket.markup.ComponentTag;
import com.voicetribe.wicket.markup.MarkupStream;
import com.voicetribe.wicket.markup.html.HtmlContainer;

/**
 * Simple &lt;a href="..."&gt; ...
 * 
 * @author Juergen Donnerstag
 */
public class SimpleHref extends HtmlContainer
{
    final private String href;
    final private String label;
    
    /**
     * Constructor.
     * 
     * @param componentName The name of this component
     */
    public SimpleHref(final String componentName, final String href, final String label)
    {
        super(componentName);
        
        this.href = href;
        this.label = label;
    }

    /**
     * Handle the component's tag
     */
    protected void handleComponentTag(RequestCycle cycle, ComponentTag tag)
    {
        if (href != null)
        {
            tag.put("href", href);
        }
    }
    
    protected void handleBody(RequestCycle cycle, MarkupStream markupStream,
            ComponentTag openTag)
    {
        this.checkTag(openTag, "a");
        replaceBody(cycle, markupStream, openTag, label);
    }
}

///////////////////////////////// End of File /////////////////////////////////
