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.service.ThreadLocale; |
18 |
| import org.apache.tapestry.IMarkupWriter; |
19 |
| import org.apache.tapestry.IRequestCycle; |
20 |
| import org.apache.tapestry.valid.IValidationDelegate; |
21 |
| import org.apache.tapestry.valid.ValidatorException; |
22 |
| |
23 |
| public class TranslatedFieldSupportImpl implements TranslatedFieldSupport |
24 |
| { |
25 |
| private ThreadLocale _threadLocale; |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
0
| public ThreadLocale getThreadLocale()
|
31 |
| { |
32 |
0
| return _threadLocale;
|
33 |
| } |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
1
| public void setThreadLocale(ThreadLocale threadLocale)
|
39 |
| { |
40 |
1
| _threadLocale = threadLocale;
|
41 |
| } |
42 |
| |
43 |
2
| public String format(TranslatedField field, Object object)
|
44 |
| { |
45 |
2
| IValidationDelegate delegate = field.getForm().getDelegate();
|
46 |
| |
47 |
2
| return delegate.isInError() ? delegate.getFieldInputValue() : field.getTranslator().format(field, object);
|
48 |
| } |
49 |
| |
50 |
2
| public Object parse(TranslatedField field, String text) throws ValidatorException
|
51 |
| { |
52 |
2
| IValidationDelegate delegate = field.getForm().getDelegate();
|
53 |
| |
54 |
2
| delegate.recordFieldInputValue(text);
|
55 |
| |
56 |
2
| return field.getTranslator().parse(field, text);
|
57 |
| } |
58 |
| |
59 |
2
| public void renderContributions(TranslatedField field, IMarkupWriter writer, IRequestCycle cycle)
|
60 |
| { |
61 |
2
| if (field.getForm().isClientValidationEnabled())
|
62 |
| { |
63 |
1
| FormComponentContributorContext context = new FormComponentContributorContextImpl(_threadLocale.getLocale(), cycle, field);
|
64 |
| |
65 |
1
| field.getTranslator().renderContribution(writer, cycle, context, field);
|
66 |
| } |
67 |
| } |
68 |
| } |