001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.components; 016 017 import org.apache.tapestry.IComponent; 018 import org.apache.tapestry.IMarkupWriter; 019 import org.apache.tapestry.IRequestCycle; 020 import org.apache.tapestry.engine.ILink; 021 022 /** 023 * A component that renders an HTML <a> element. It exposes some 024 * properties to the components it wraps. This is basically to facilitate 025 * the {@link org.apache.tapestry.html.Rollover} component. 026 * 027 * @author Howard Lewis Ship 028 * 029 **/ 030 031 public interface ILinkComponent extends IComponent 032 { 033 034 /** 035 * Returns whether this service link component is enabled or disabled. 036 * 037 * @since 0.2.9 038 * 039 **/ 040 041 public boolean isDisabled(); 042 043 /** 044 * Returns the anchor defined for this link, or null for no anchor. 045 * 046 * @since 3.0 047 * 048 **/ 049 050 public String getAnchor(); 051 052 /** 053 * Returns the name of the target window or frame for this link, 054 * or null if current window or frame is to be used. 055 * 056 * @since 4.0 057 */ 058 public String getTarget(); 059 060 /** 061 * Adds a new event handler. When the event occurs, the JavaScript function 062 * specified is executed. Multiple functions can be specified, in which case 063 * all of them are executed. 064 * 065 * <p>This was created for use by 066 * {@link org.apache.tapestry.html.Rollover} to set mouse over and mouse out handlers on 067 * the {@link ILinkComponent} that wraps it, but can be used for 068 * many other things as well. 069 * 070 * @since 0.2.9 071 **/ 072 073 public void addEventHandler(LinkEventType type, String functionName); 074 075 /** 076 * Invoked by the {@link org.apache.tapestry.link.ILinkRenderer} (if 077 * the link is not disabled) to provide a 078 * {@link org.apache.tapestry.engine.EngineServiceLink} that the renderer can convert 079 * into a URL. 080 * 081 **/ 082 083 public ILink getLink(IRequestCycle cycle); 084 085 /** 086 * Invoked (by the {@link org.apache.tapestry.link.ILinkRenderer}) 087 * to make the link render any additional attributes. These 088 * are informal parameters, plus any attributes related to events. 089 * This is only invoked for non-disabled links. 090 * 091 * @since 3.0 092 * 093 **/ 094 095 public void renderAdditionalAttributes(IMarkupWriter writer, IRequestCycle cycle); 096 }