1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.binding.value.command;
17
18 import java.lang.reflect.Field;
19 import java.util.List;
20
21 import org.seasar.framework.beans.PropertyDesc;
22 import org.seasar.framework.util.StringUtil;
23 import org.seasar.uruma.annotation.ImportExportValue;
24 import org.seasar.uruma.annotation.ImportValue;
25 import org.seasar.uruma.binding.value.BindingCommand;
26 import org.seasar.uruma.binding.value.ValueBinder;
27 import org.seasar.uruma.component.UIComponent;
28 import org.seasar.uruma.desc.FormDesc;
29
30
31
32
33
34
35 public class ImportValueCommand extends AbstractBindingCommand<ImportValue> {
36
37
38
39
40 public List<PropertyDesc> getTargetPropertyDescs(final FormDesc desc) {
41 return desc.getImportValueProperties();
42 }
43
44
45
46
47
48
49 @Override
50 protected void doBind(final ValueBinder binder, final Object widget,
51 final Object formObj, final PropertyDesc propDesc,
52 final UIComponent uiComp) {
53 binder.importValue(widget, formObj, propDesc, uiComp);
54 }
55
56
57
58
59 @Override
60 public String getId(final Field field) {
61 ImportValue importValue = field.getAnnotation(ImportValue.class);
62 if (importValue != null) {
63 String id = importValue.id();
64 return StringUtil.isEmpty(id) ? field.getName() : id;
65 }
66
67 ImportExportValue importExportValue = field
68 .getAnnotation(ImportExportValue.class);
69 if (importExportValue != null) {
70 String id = importExportValue.id();
71 return StringUtil.isEmpty(id) ? field.getName() : id;
72 }
73
74 return field.getName();
75 }
76
77
78
79
80 @Override
81 protected String getId(final ImportValue annotation) {
82 return annotation.id();
83 }
84
85
86
87
88 @Override
89 protected ImportValue getAnnotation(final Field field) {
90 return field.getAnnotation(ImportValue.class);
91 }
92 }