1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.lifecycle.initialize;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.rice.krad.uif.component.Component;
22 import org.kuali.rice.krad.uif.container.Container;
23 import org.kuali.rice.krad.uif.field.InputField;
24 import org.kuali.rice.krad.uif.field.RemoteFieldsHolder;
25 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle;
26 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycleTaskBase;
27 import org.kuali.rice.krad.uif.view.ViewModel;
28
29
30
31
32
33
34 public class ProcessRemoteFieldsHolderTask extends ViewLifecycleTaskBase<Container> {
35
36
37
38
39 public ProcessRemoteFieldsHolderTask() {
40 super(Container.class);
41 }
42
43
44
45
46
47
48 @Override
49 protected void performLifecycleTask() {
50 Container container = (Container) getElementState().getElement();
51
52 if (!container.isProcessRemoteFieldHolders()) {
53 return;
54 }
55
56 List<Component> processedItems = new ArrayList<Component>();
57
58
59
60 for (Component item : container.getItems()) {
61 if (item instanceof RemoteFieldsHolder) {
62 List<InputField> translatedFields = ((RemoteFieldsHolder) item)
63 .fetchAndTranslateRemoteFields(container);
64 processedItems.addAll(translatedFields);
65 } else {
66 processedItems.add(item);
67 }
68 }
69
70
71 container.setItems(processedItems);
72
73
74
75 ViewLifecycle.getHelper().addCustomContainerComponents((ViewModel)ViewLifecycle.getModel(),
76 (Container) getElementState().getElement());
77 }
78
79 }