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 |
8
| protected boolean getCanTakeFocus()
|
39 |
| { |
40 |
8
| return false;
|
41 |
| } |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
8
| protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
|
48 |
| { |
49 |
8
| IForm form = getForm();
|
50 |
8
| String externalValue = null;
|
51 |
| |
52 |
8
| if (getEncode())
|
53 |
| { |
54 |
4
| Object value = getValue();
|
55 |
| |
56 |
4
| try
|
57 |
| { |
58 |
4
| 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 |
4
| externalValue = (String) getBinding("value").getObject(String.class);
|
67 |
| |
68 |
8
| String id = getClientId();
|
69 |
| |
70 |
8
| form.addHiddenValue(getName(), id, externalValue);
|
71 |
| } |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
8
| protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
|
77 |
| { |
78 |
8
| String parameter = cycle.getParameter(getName());
|
79 |
| |
80 |
8
| Object value = parameter;
|
81 |
| |
82 |
8
| if (getEncode())
|
83 |
| { |
84 |
4
| try
|
85 |
| { |
86 |
4
| 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 |
8
| setValue(value);
|
98 |
| |
99 |
8
| 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 |
| } |