| 1 |
|
package net.sf.tacos.components; |
| 2 |
|
|
| 3 |
|
import java.util.HashMap; |
| 4 |
|
import java.util.Map; |
| 5 |
|
|
| 6 |
|
import org.apache.tapestry.AbstractComponent; |
| 7 |
|
import org.apache.tapestry.IActionListener; |
| 8 |
|
import org.apache.tapestry.IDirect; |
| 9 |
|
import org.apache.tapestry.IMarkupWriter; |
| 10 |
|
import org.apache.tapestry.IRequestCycle; |
| 11 |
|
import org.apache.tapestry.IScript; |
| 12 |
|
import org.apache.tapestry.Tapestry; |
| 13 |
|
import org.apache.tapestry.TapestryUtils; |
| 14 |
|
import org.apache.tapestry.engine.DirectServiceParameter; |
| 15 |
|
import org.apache.tapestry.engine.IEngineService; |
| 16 |
|
import org.apache.tapestry.engine.ILink; |
| 17 |
|
import org.apache.tapestry.listener.ListenerInvoker; |
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
0 |
public abstract class ClientLink extends AbstractComponent implements IDirect{ |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { |
| 44 |
0 |
renderBody(writer, cycle); |
| 45 |
|
|
| 46 |
0 |
if (!cycle.isRewinding()) { |
| 47 |
0 |
Map params = new HashMap(); |
| 48 |
0 |
params.put("url", getLink().getURL()); |
| 49 |
0 |
params.put("function", getFunction()); |
| 50 |
0 |
getScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), params); |
| 51 |
|
} |
| 52 |
0 |
} |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
public void trigger(IRequestCycle cycle) { |
| 58 |
0 |
IActionListener listener = getListener(); |
| 59 |
0 |
if (listener == null) |
| 60 |
0 |
throw Tapestry.createRequiredParameterException(this, "listener"); |
| 61 |
|
|
| 62 |
0 |
getListenerInvoker().invokeListener(listener, this, cycle); |
| 63 |
0 |
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
private ILink getLink(){ |
| 67 |
0 |
DirectServiceParameter dsp = new DirectServiceParameter(this); |
| 68 |
0 |
return getEngine().getLink(isStateful(), dsp); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
public abstract IActionListener getListener(); |
| 73 |
|
|
| 74 |
|
public abstract String getFunction(); |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
public abstract IScript getScript(); |
| 78 |
|
|
| 79 |
|
public abstract ListenerInvoker getListenerInvoker(); |
| 80 |
|
|
| 81 |
|
public abstract IEngineService getEngine(); |
| 82 |
|
} |