1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
package org.apache.tapestry.contrib.form.checkboxes; |
16 |
|
|
17 |
|
import java.util.Collection; |
18 |
|
|
19 |
|
import org.apache.tapestry.BaseComponent; |
20 |
|
import org.apache.tapestry.IMarkupWriter; |
21 |
|
import org.apache.tapestry.IRequestCycle; |
22 |
|
import org.apache.tapestry.PageRenderSupport; |
23 |
|
import org.apache.tapestry.TapestryUtils; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
0 |
public abstract class CheckboxGroup extends BaseComponent |
30 |
|
{ |
31 |
|
public static final String CHECKBOX_GROUP_ATTRIBUTE = "org.apache.tapestry.contrib.form.CheckboxGroup"; |
32 |
|
|
33 |
|
public abstract Collection getCheckboxNames(); |
34 |
|
public abstract String getFunctionName(); |
35 |
|
public abstract void setFunctionName(String functionName); |
36 |
|
|
37 |
|
public void registerControlledCheckbox(ControlledCheckbox checkbox) |
38 |
|
{ |
39 |
0 |
String name = checkbox.getCheckboxName(); |
40 |
0 |
String form = checkbox.getForm().getName(); |
41 |
0 |
getCheckboxNames().add(form + "." + name); |
42 |
0 |
} |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
48 |
|
{ |
49 |
0 |
Object objOtherGroup = cycle.getAttribute(CHECKBOX_GROUP_ATTRIBUTE); |
50 |
0 |
cycle.setAttribute(CHECKBOX_GROUP_ATTRIBUTE, this); |
51 |
|
|
52 |
0 |
initialize(cycle); |
53 |
|
|
54 |
0 |
super.renderComponent(writer, cycle); |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
0 |
getCheckboxNames().clear(); |
59 |
|
|
60 |
0 |
cycle.setAttribute(CHECKBOX_GROUP_ATTRIBUTE, objOtherGroup); |
61 |
0 |
} |
62 |
|
|
63 |
|
private void initialize(IRequestCycle cycle) |
64 |
|
{ |
65 |
0 |
String functionName = "setCheckboxGroup"; |
66 |
|
|
67 |
0 |
if (!cycle.isRewinding()) { |
68 |
0 |
PageRenderSupport body = TapestryUtils.getPageRenderSupport(cycle, this); |
69 |
0 |
if (body != null) |
70 |
0 |
functionName = body.getUniqueString("setCheckboxGroup"); |
71 |
|
} |
72 |
|
|
73 |
0 |
setFunctionName(functionName); |
74 |
0 |
} |
75 |
|
|
76 |
|
} |