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 015package org.apache.tapestry.link; 016 017import org.apache.tapestry.IAction; 018import org.apache.tapestry.IActionListener; 019import org.apache.tapestry.IRequestCycle; 020import org.apache.tapestry.RenderRewoundException; 021import org.apache.tapestry.Tapestry; 022import org.apache.tapestry.engine.ActionServiceParameter; 023import org.apache.tapestry.engine.ILink; 024import org.apache.tapestry.listener.ListenerInvoker; 025 026/** 027 * A component for creating a link that is handled using the action service. [ <a 028 * href="../../../../../ComponentReference/ActionLink.html">Component Reference </a>] 029 * 030 * @author Howard Lewis Ship 031 * @deprecated To be removed in 4.1 032 */ 033 034public abstract class ActionLink extends AbstractLinkComponent implements IAction 035{ 036 public abstract boolean isStateful(); 037 038 /** 039 * Returns true if the stateful parameter is bound to a true value. If stateful is not bound, 040 * also returns the default, true. 041 * <p> 042 * Note that this method can be called when the component is not rendering, therefore it must 043 * directly access the {@link IBinding}for the stateful parameter. 044 */ 045 046 public boolean getRequiresSession() 047 { 048 return isStateful(); 049 } 050 051 public ILink getLink(IRequestCycle cycle) 052 { 053 String actionId = cycle.getNextActionId(); 054 055 if (cycle.isRewound(this)) 056 { 057 getListenerInvoker().invokeListener(getListener(), this, cycle); 058 059 throw new RenderRewoundException(this); 060 } 061 062 return getLink(cycle, Tapestry.ACTION_SERVICE, new ActionServiceParameter(this, actionId)); 063 } 064 065 public abstract IActionListener getListener(); 066 067 public abstract ListenerInvoker getListenerInvoker(); 068}