1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.view;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.seasar.tuigwaa.database.function.UpdateExeFunction;
23 import org.seasar.tuigwaa.model.core.TgwAttribute;
24 import org.seasar.tuigwaa.model.core.TgwEntity;
25
26 public class CustomFormComponent extends EntityFormComponent {
27
28 private UpdateExeFunction updateExe;
29
30 public CustomFormComponent(String javascript, TgwEntity entity,
31 Object object, UpdateExeFunction updateExe) {
32 super(javascript, entity, object);
33 this.updateExe = updateExe;
34 }
35
36 public String getCustomFormName() {
37 return updateExe.getName();
38 }
39
40 public String getName() {
41 return updateExe.getName();
42 }
43
44 public List getFormElements() {
45 List list = new ArrayList();
46 Iterator itr = getEntity().getFieldIterator();
47 while (itr.hasNext()) {
48 TgwAttribute field = (TgwAttribute) itr.next();
49 String fieldName = field.getName();
50 if (needAttribute(fieldName)) {
51 FormElement elem = createFormElement(field);
52 if (elem != null) {
53 list.add(elem);
54 }
55 String hidden = createExtraHidden(field);
56 addExtraHidden(hidden);
57 }
58 }
59 return list;
60 }
61
62 private boolean needAttribute(String attrName) {
63 return updateExe.getDtoFieldList().contains(attrName);
64 }
65
66 protected FormElement getRowElement(TgwAttribute attr) {
67 if (needAttribute(attr.getName())) {
68 return createFormElement(attr);
69 } else {
70
71 Object obj = DataViewUtils.getTableData(getValueObject(), attr);
72 return new FormElement(attr.getName(), null, attr.getDisplayName(),
73 String.valueOf(obj), false, "");
74 }
75 }
76 }