1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.contrib.form; |
16 | |
|
17 | |
import org.apache.tapestry.IMarkupWriter; |
18 | |
import org.apache.tapestry.IRequestCycle; |
19 | |
import org.apache.tapestry.form.IPropertySelectionModel; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class CheckBoxMultiplePropertySelectionRenderer |
30 | |
implements IMultiplePropertySelectionRenderer |
31 | |
{ |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public void beginRender( |
39 | |
MultiplePropertySelection component, |
40 | |
IMarkupWriter writer, |
41 | |
IRequestCycle cycle) |
42 | |
{ |
43 | 0 | writer.begin("table"); |
44 | 0 | writer.attribute("border", 0); |
45 | 0 | writer.attribute("cellpadding", 0); |
46 | 0 | writer.attribute("cellspacing", 2); |
47 | 0 | } |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
public void endRender( |
55 | |
MultiplePropertySelection component, |
56 | |
IMarkupWriter writer, |
57 | |
IRequestCycle cycle) |
58 | |
{ |
59 | 0 | writer.end(); |
60 | 0 | } |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
public void renderOption( |
69 | |
MultiplePropertySelection component, |
70 | |
IMarkupWriter writer, |
71 | |
IRequestCycle cycle, |
72 | |
IPropertySelectionModel model, |
73 | |
Object option, |
74 | |
int index, |
75 | |
boolean selected) |
76 | |
{ |
77 | 0 | writer.begin("tr"); |
78 | 0 | writer.begin("td"); |
79 | |
|
80 | 0 | writer.beginEmpty("input"); |
81 | 0 | writer.attribute("type", "checkbox"); |
82 | 0 | writer.attribute("name", component.getName()); |
83 | 0 | String id = component.getName() + "." +model.getValue(index); |
84 | 0 | writer.attribute("id", id); |
85 | 0 | writer.attribute("value", model.getValue(index)); |
86 | |
|
87 | 0 | if (component.isDisabled()) |
88 | 0 | writer.attribute("disabled", "disabled"); |
89 | |
|
90 | 0 | if (selected) |
91 | 0 | writer.attribute("checked", "checked"); |
92 | |
|
93 | 0 | writer.end(); |
94 | |
|
95 | 0 | writer.println(); |
96 | |
|
97 | 0 | writer.begin("td"); |
98 | 0 | writer.begin("label"); |
99 | 0 | writer.attribute("for", id); |
100 | 0 | writer.print(model.getLabel(index)); |
101 | 0 | writer.end(); |
102 | 0 | writer.end(); |
103 | 0 | writer.end(); |
104 | |
|
105 | 0 | writer.println(); |
106 | 0 | } |
107 | |
} |