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