KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > link > ActionLink


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.link;
16
17 import org.apache.tapestry.IAction;
18 import org.apache.tapestry.IActionListener;
19 import org.apache.tapestry.IBinding;
20 import org.apache.tapestry.IRequestCycle;
21 import org.apache.tapestry.RenderRewoundException;
22 import org.apache.tapestry.Tapestry;
23 import org.apache.tapestry.engine.ActionServiceParameter;
24 import org.apache.tapestry.engine.ILink;
25 import org.apache.tapestry.listener.ListenerInvoker;
26
27 /**
28  * A component for creating a link that is handled using the action service. [ <a
29  * HREF="../../../../../ComponentReference/ActionLink.html">Component Reference </a>]
30  *
31  * @author Howard Lewis Ship
32  */

33
34 public abstract class ActionLink extends AbstractLinkComponent implements IAction
35 {
36     public abstract boolean isStateful();
37
38     /**
39      * Returns true if the stateful parameter is bound to a true value. If stateful is not bound,
40      * also returns the default, true.
41      * <p>
42      * Note that this method can be called when the component is not rendering, therefore it must
43      * directly access the {@link IBinding}for the stateful parameter.
44      */

45
46     public boolean getRequiresSession()
47     {
48         return isStateful();
49     }
50
51     public ILink getLink(IRequestCycle cycle)
52     {
53         String JavaDoc actionId = cycle.getNextActionId();
54
55         if (cycle.isRewound(this))
56         {
57             getListenerInvoker().invokeListener(getListener(), this, cycle);
58
59             throw new RenderRewoundException(this);
60         }
61
62         return getLink(cycle, Tapestry.ACTION_SERVICE, new ActionServiceParameter(this, actionId));
63     }
64
65     public abstract IActionListener getListener();
66
67     public abstract ListenerInvoker getListenerInvoker();
68 }
Popular Tags