|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.form; |
|
16 |
| |
|
17 |
| import org.apache.hivemind.ApplicationRuntimeException; |
|
18 |
| import org.apache.tapestry.IActionListener; |
|
19 |
| import org.apache.tapestry.IForm; |
|
20 |
| import org.apache.tapestry.IMarkupWriter; |
|
21 |
| import org.apache.tapestry.IRequestCycle; |
|
22 |
| import org.apache.tapestry.listener.ListenerInvoker; |
|
23 |
| import org.apache.tapestry.services.DataSqueezer; |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| public abstract class Hidden extends AbstractFormComponent |
|
33 |
| { |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
12
| protected boolean getCanTakeFocus()
|
|
39 |
| { |
|
40 |
12
| return false;
|
|
41 |
| } |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
12
| protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
|
|
48 |
| { |
|
49 |
12
| IForm form = getForm();
|
|
50 |
12
| String externalValue = null;
|
|
51 |
| |
|
52 |
12
| if (getEncode())
|
|
53 |
| { |
|
54 |
6
| Object value = getValue();
|
|
55 |
| |
|
56 |
6
| try
|
|
57 |
| { |
|
58 |
6
| externalValue = getDataSqueezer().squeeze(value);
|
|
59 |
| } |
|
60 |
| catch (Exception e) |
|
61 |
| { |
|
62 |
0
| throw new ApplicationRuntimeException(e.getMessage(), this, null, e);
|
|
63 |
| } |
|
64 |
| } |
|
65 |
| else |
|
66 |
6
| externalValue = (String) getBinding("value").getObject(String.class);
|
|
67 |
| |
|
68 |
12
| String id = getClientId();
|
|
69 |
| |
|
70 |
12
| form.addHiddenValue(getName(), id, externalValue);
|
|
71 |
| } |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
12
| protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
|
|
77 |
| { |
|
78 |
12
| String parameter = cycle.getParameter(getName());
|
|
79 |
| |
|
80 |
12
| Object value = parameter;
|
|
81 |
| |
|
82 |
12
| if (getEncode())
|
|
83 |
| { |
|
84 |
6
| try
|
|
85 |
| { |
|
86 |
6
| value = getDataSqueezer().unsqueeze(parameter);
|
|
87 |
| } |
|
88 |
| catch (Exception ex) |
|
89 |
| { |
|
90 |
0
| throw new ApplicationRuntimeException(ex.getMessage(), this, null, ex);
|
|
91 |
| } |
|
92 |
| } |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
12
| setValue(value);
|
|
98 |
| |
|
99 |
12
| getListenerInvoker().invokeListener(getListener(), this, cycle);
|
|
100 |
| } |
|
101 |
| |
|
102 |
| |
|
103 |
| public abstract DataSqueezer getDataSqueezer(); |
|
104 |
| |
|
105 |
| public abstract Object getValue(); |
|
106 |
| |
|
107 |
| public abstract void setValue(Object value); |
|
108 |
| |
|
109 |
| public abstract IActionListener getListener(); |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
| public abstract ListenerInvoker getListenerInvoker(); |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
0
| public boolean isDisabled()
|
|
125 |
| { |
|
126 |
0
| return false;
|
|
127 |
| } |
|
128 |
| |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
| |
|
135 |
| public abstract boolean getEncode(); |
|
136 |
| } |