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 |
8
| protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
|
41 |
| { |
42 |
8
| String value = getTranslatedFieldSupport().format(this, getValue());
|
43 |
| |
44 |
8
| renderDelegatePrefix(writer, cycle);
|
45 |
| |
46 |
8
| writer.begin("textarea");
|
47 |
| |
48 |
8
| writer.attribute("name", getName());
|
49 |
| |
50 |
8
| if (isDisabled())
|
51 |
2
| writer.attribute("disabled", "disabled");
|
52 |
| |
53 |
8
| renderIdAttribute(writer, cycle);
|
54 |
| |
55 |
8
| renderDelegateAttributes(writer, cycle);
|
56 |
| |
57 |
8
| getTranslatedFieldSupport().renderContributions(this, writer, cycle);
|
58 |
8
| getValidatableFieldSupport().renderContributions(this, writer, cycle);
|
59 |
| |
60 |
8
| renderInformalParameters(writer, cycle);
|
61 |
| |
62 |
8
| if (value != null)
|
63 |
8
| writer.print(value);
|
64 |
| |
65 |
8
| writer.end();
|
66 |
| |
67 |
8
| renderDelegateSuffix(writer, cycle);
|
68 |
| } |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
6
| protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
|
74 |
| { |
75 |
6
| String value = cycle.getParameter(getName());
|
76 |
| |
77 |
6
| try
|
78 |
| { |
79 |
6
| String text = (String) getTranslatedFieldSupport().parse(this, value);
|
80 |
| |
81 |
4
| getValidatableFieldSupport().validate(this, writer, cycle, text);
|
82 |
| |
83 |
2
| setValue(text);
|
84 |
| } |
85 |
| catch (ValidatorException e) |
86 |
| { |
87 |
4
| 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 |
| } |