1 package net.sf.flock.webapp.folding;
2
3 import net.sf.tapestry.AbstractComponent;
4 import net.sf.tapestry.IAsset;
5 import net.sf.tapestry.IMarkupWriter;
6 import net.sf.tapestry.IRequestCycle;
7 import net.sf.tapestry.RequestCycleException;
8 import net.sf.tapestry.html.Body;
9
10 public class FoldImage extends AbstractComponent {
11
12 private boolean disabled;
13 private boolean folded;
14
15 private IAsset openImage;
16 private IAsset closedImage;
17 private IAsset disabledOpenImage;
18 private IAsset disabledClosedImage;
19
20 /***
21 * @see net.sf.tapestry.AbstractComponent#renderComponent(net.sf.tapestry.IMarkupWriter, net.sf.tapestry.IRequestCycle)
22 */
23 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException {
24
25 if (cycle.isRewinding()) {
26 // has no body -> no need to rewind
27 return;
28 }
29
30 // get Body and contribute script asset
31 Body body = Body.get(cycle);
32 IAsset script = this.getAsset("foldingScript");
33 body.includeScript( script.buildURL(cycle) );
34
35 String openImageURL = this.disabled ? disabledOpenImage.buildURL(cycle) : this.openImage.buildURL(cycle);
36 String closedImageURL = this.disabled ? disabledClosedImage.buildURL(cycle) : this.closedImage.buildURL(cycle);
37
38 writer.beginEmpty("img");
39
40 writer.attribute("src", folded ? closedImageURL : openImageURL);
41 writer.attribute("border", 0);
42
43 if (!disabled) {
44 writer.attribute("style", "cursor:pointer;cursor:hand;");
45 writer.attribute("onClick", "folding_fold(this, '"+openImageURL+"', '"+closedImageURL+"');");
46 }
47
48 // informal attributes
49 this.generateAttributes(writer, cycle);
50
51 writer.closeTag();
52
53 }
54
55 public boolean isDisabled() {
56 return disabled;
57 }
58
59 public void setDisabled(boolean disabled) {
60 this.disabled = disabled;
61 }
62
63 public boolean isFolded() {
64 return folded;
65 }
66
67 public void setFolded(boolean folded) {
68 this.folded = folded;
69 }
70
71 public IAsset getClosedImage() {
72 return closedImage;
73 }
74
75 public void setClosedImage(IAsset closedImage) {
76 this.closedImage = closedImage;
77 }
78
79 public IAsset getOpenImage() {
80 return openImage;
81 }
82
83 public void setOpenImage(IAsset openImage) {
84 this.openImage = openImage;
85 }
86
87 public IAsset getDisabledClosedImage() {
88 return disabledClosedImage;
89 }
90
91 public void setDisabledClosedImage(IAsset disabledClosedImage) {
92 this.disabledClosedImage = disabledClosedImage;
93 }
94
95 public IAsset getDisabledOpenImage() {
96 return disabledOpenImage;
97 }
98
99 public void setDisabledOpenImage(IAsset disabledOpenImage) {
100 this.disabledOpenImage = disabledOpenImage;
101 }
102
103 }
This page was automatically generated by Maven