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