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