1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.form; |
16 |
| |
17 |
| import java.util.HashMap; |
18 |
| import java.util.Map; |
19 |
| |
20 |
| import org.apache.hivemind.ApplicationRuntimeException; |
21 |
| import org.apache.hivemind.HiveMind; |
22 |
| import org.apache.tapestry.IComponent; |
23 |
| import org.apache.tapestry.IForm; |
24 |
| import org.apache.tapestry.IMarkupWriter; |
25 |
| import org.apache.tapestry.IRequestCycle; |
26 |
| import org.apache.tapestry.IScript; |
27 |
| import org.apache.tapestry.PageRenderSupport; |
28 |
| import org.apache.tapestry.TapestryUtils; |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| public abstract class LinkSubmit extends AbstractSubmit |
38 |
| { |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| public static final String ATTRIBUTE_NAME = "org.apache.tapestry.form.LinkSubmit"; |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
3
| protected boolean isClicked(IRequestCycle cycle, String name)
|
52 |
| { |
53 |
3
| String value = cycle.getParameter(FormConstants.SUBMIT_NAME_PARAMETER);
|
54 |
| |
55 |
3
| return name.equals(value);
|
56 |
| } |
57 |
| |
58 |
| public abstract IScript getScript(); |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
2
| protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
|
65 |
| { |
66 |
2
| boolean disabled = isDisabled();
|
67 |
| |
68 |
2
| IForm form = getForm();
|
69 |
2
| String name = getName();
|
70 |
| |
71 |
2
| if (!disabled)
|
72 |
| { |
73 |
1
| PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);
|
74 |
| |
75 |
1
| Map symbols = new HashMap();
|
76 |
1
| symbols.put("form", form);
|
77 |
1
| symbols.put("name", name);
|
78 |
| |
79 |
1
| getScript().execute(cycle, pageRenderSupport, symbols);
|
80 |
| |
81 |
1
| writer.begin("a");
|
82 |
1
| writer.attribute("href", (String) symbols.get("href"));
|
83 |
| |
84 |
1
| renderIdAttribute(writer, cycle);
|
85 |
| |
86 |
1
| renderInformalParameters(writer, cycle);
|
87 |
| } |
88 |
| |
89 |
2
| renderBody(writer, cycle);
|
90 |
| |
91 |
2
| if (!disabled)
|
92 |
1
| writer.end();
|
93 |
| |
94 |
| } |
95 |
| |
96 |
| |
97 |
| |
98 |
| |
99 |
2
| protected void prepareForRender(IRequestCycle cycle)
|
100 |
| { |
101 |
2
| IComponent outer = (IComponent) cycle.getAttribute(ATTRIBUTE_NAME);
|
102 |
| |
103 |
2
| if (outer != null)
|
104 |
1
| throw new ApplicationRuntimeException(FormMessages.linkSubmitMayNotNest(this, outer),
|
105 |
| this, getLocation(), null); |
106 |
| |
107 |
1
| cycle.setAttribute(ATTRIBUTE_NAME, this);
|
108 |
| } |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
1
| protected void cleanupAfterRender(IRequestCycle cycle)
|
114 |
| { |
115 |
1
| cycle.removeAttribute(ATTRIBUTE_NAME);
|
116 |
| } |
117 |
| |
118 |
| |
119 |
| |
120 |
| |
121 |
0
| protected boolean getCanTakeFocus()
|
122 |
| { |
123 |
0
| return false;
|
124 |
| } |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
1
| protected boolean getRenderBodyOnRewind()
|
131 |
| { |
132 |
1
| return true;
|
133 |
| } |
134 |
| |
135 |
| } |