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.tapestry.IMarkupWriter; |
18 | |
import org.apache.tapestry.IRequestCycle; |
19 | |
import org.apache.tapestry.valid.ValidatorException; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public abstract class TextArea extends AbstractFormComponent implements TranslatedField { |
31 | |
|
32 | |
public abstract Object getValue(); |
33 | |
|
34 | |
public abstract void setValue(Object value); |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle) |
41 | |
{ |
42 | 0 | String value = getTranslatedFieldSupport().format(this, getValue()); |
43 | |
|
44 | 0 | renderDelegatePrefix(writer, cycle); |
45 | |
|
46 | 0 | writer.begin("textarea"); |
47 | |
|
48 | 0 | writer.attribute("name", getName()); |
49 | |
|
50 | 0 | if (isDisabled()) |
51 | 0 | writer.attribute("disabled", "disabled"); |
52 | |
|
53 | 0 | renderIdAttribute(writer, cycle); |
54 | |
|
55 | 0 | renderDelegateAttributes(writer, cycle); |
56 | |
|
57 | 0 | getTranslatedFieldSupport().renderContributions(this, writer, cycle); |
58 | 0 | getValidatableFieldSupport().renderContributions(this, writer, cycle); |
59 | |
|
60 | 0 | renderInformalParameters(writer, cycle); |
61 | |
|
62 | 0 | if (value != null) |
63 | 0 | writer.print(value); |
64 | |
|
65 | 0 | writer.end(); |
66 | |
|
67 | 0 | renderDelegateSuffix(writer, cycle); |
68 | 0 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle) |
75 | |
{ |
76 | 0 | String value = cycle.getParameter(getName()); |
77 | |
|
78 | |
try |
79 | |
{ |
80 | 0 | String text = (String) getTranslatedFieldSupport().parse(this, value); |
81 | |
|
82 | 0 | getValidatableFieldSupport().validate(this, writer, cycle, text); |
83 | |
|
84 | 0 | setValue(text); |
85 | |
} |
86 | 0 | catch (ValidatorException e) |
87 | |
{ |
88 | 0 | getForm().getDelegate().record(e); |
89 | 0 | } |
90 | 0 | } |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
public abstract ValidatableFieldSupport getValidatableFieldSupport(); |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public abstract TranslatedFieldSupport getTranslatedFieldSupport(); |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
public boolean isRequired() |
106 | |
{ |
107 | 0 | return getValidatableFieldSupport().isRequired(this); |
108 | |
} |
109 | |
} |