1 package net.sf.tacos.components.scriptaculous;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import org.apache.tapestry.BaseComponent;
7 import org.apache.tapestry.IMarkupWriter;
8 import org.apache.tapestry.IRequestCycle;
9 import org.apache.tapestry.IScript;
10 import org.apache.tapestry.TapestryUtils;
11 import org.apache.tapestry.components.Block;
12 import org.apache.tapestry.json.JSONObject;
13
14
15
16
17
18
19
20 public abstract class Glider extends BaseComponent {
21
22
23
24
25 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
26 writer.begin("div");
27 renderIdAttribute(writer, cycle);
28 renderInformalParameters(writer, cycle);
29 super.renderComponent(writer, cycle);
30
31 writer.end();
32
33 JSONObject json = new JSONObject();
34 json.put("duration", getDuration());
35
36 Map parms = new HashMap();
37 parms.put("props", json.toString());
38 parms.put("component", this);
39
40 getScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), parms);
41 }
42
43 public String getSectionId(int index){
44 return "section"+(++index);
45 }
46
47 public abstract double getDuration();
48
49
50 public abstract IScript getScript();
51
52 }