|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.wml; |
|
16 |
| |
|
17 |
| import org.apache.hivemind.ApplicationRuntimeException; |
|
18 |
| import org.apache.hivemind.HiveMind; |
|
19 |
| import org.apache.tapestry.AbstractComponent; |
|
20 |
| import org.apache.tapestry.IMarkupWriter; |
|
21 |
| import org.apache.tapestry.IRequestCycle; |
|
22 |
| import org.apache.tapestry.Tapestry; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| public abstract class Select extends AbstractComponent |
|
34 |
| { |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| private final static String ATTRIBUTE_NAME = "org.apache.tapestry.active.Select"; |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
21
| protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
|
|
47 |
| { |
|
48 |
21
| if (cycle.getAttribute(ATTRIBUTE_NAME) != null)
|
|
49 |
3
| throw new ApplicationRuntimeException(Tapestry.getMessage("Select.may-not-nest"), this,
|
|
50 |
| null, null); |
|
51 |
| |
|
52 |
18
| cycle.setAttribute(ATTRIBUTE_NAME, this);
|
|
53 |
| |
|
54 |
18
| boolean render = !cycle.isRewinding();
|
|
55 |
| |
|
56 |
18
| if (render)
|
|
57 |
| { |
|
58 |
15
| writer.begin("select");
|
|
59 |
| |
|
60 |
15
| writer.attribute("name", getName());
|
|
61 |
| |
|
62 |
15
| String value = getValue();
|
|
63 |
15
| if (HiveMind.isNonBlank(value))
|
|
64 |
3
| writer.attribute("value", value);
|
|
65 |
| |
|
66 |
15
| String title = getTitle();
|
|
67 |
15
| if (HiveMind.isNonBlank(title))
|
|
68 |
12
| writer.attribute("title", title);
|
|
69 |
| |
|
70 |
15
| boolean multiple = isMultiple();
|
|
71 |
15
| if (multiple)
|
|
72 |
3
| writer.attribute("multiple", multiple);
|
|
73 |
| |
|
74 |
15
| renderInformalParameters(writer, cycle);
|
|
75 |
| } |
|
76 |
| |
|
77 |
18
| renderBody(writer, cycle);
|
|
78 |
| |
|
79 |
15
| if (render)
|
|
80 |
| { |
|
81 |
12
| writer.end();
|
|
82 |
| } |
|
83 |
| |
|
84 |
15
| cycle.removeAttribute(ATTRIBUTE_NAME);
|
|
85 |
| } |
|
86 |
| |
|
87 |
| public abstract boolean isMultiple(); |
|
88 |
| |
|
89 |
| public abstract String getName(); |
|
90 |
| |
|
91 |
| public abstract String getValue(); |
|
92 |
| |
|
93 |
| public abstract String getTitle(); |
|
94 |
| } |