KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > pets > presentation > components > DirectArea


1 package org.apache.tapestry.pets.presentation.components;
2
3
4 import org.apache.tapestry.AbstractComponent;
5 import org.apache.tapestry.IActionListener;
6 import org.apache.tapestry.IDirect;
7 import org.apache.tapestry.IMarkupWriter;
8 import org.apache.tapestry.IRequestCycle;
9 import org.apache.tapestry.Tapestry;
10 import org.apache.tapestry.engine.IEngineService;
11 import org.apache.tapestry.engine.ILink;
12 import org.apache.tapestry.link.DirectLink;
13
14 public abstract class DirectArea extends AbstractComponent implements IDirect
15 {
16     public abstract IActionListener getListener();
17     public abstract Object JavaDoc getParameters();
18
19     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
20     {
21         if (cycle.isRewinding())
22             return;
23
24         Object JavaDoc[] parameters = DirectLink.constructServiceParameters(getParameters());
25
26         IEngineService service = cycle.getEngine().getService(Tapestry.DIRECT_SERVICE);
27         ILink link = service.getLink(cycle, this, parameters);
28
29         writer.beginEmpty("area");
30         writer.attribute("href", link.getURL());
31
32         renderInformalParameters(writer, cycle);
33     }
34
35     public void trigger(IRequestCycle cycle)
36     {
37         IActionListener listener = getListener();
38
39         if (listener == null)
40             throw Tapestry.createRequiredParameterException(this, "listener");
41
42         listener.actionTriggered(this, cycle);
43     }
44
45     public boolean isStateful()
46     {
47         return false;
48     }
49
50 }
51
52
Popular Tags