1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.util;
17
18 import org.kuali.rice.krad.uif.component.Component;
19 import org.kuali.rice.krad.uif.component.PropertyReplacer;
20 import org.kuali.rice.krad.uif.container.CollectionFilter;
21 import org.kuali.rice.krad.uif.container.CollectionGroup;
22 import org.kuali.rice.krad.uif.container.Container;
23 import org.kuali.rice.krad.uif.container.PageGroup;
24 import org.kuali.rice.krad.uif.element.Action;
25 import org.kuali.rice.krad.uif.field.InputField;
26 import org.kuali.rice.krad.uif.modifier.ComponentModifier;
27 import org.kuali.rice.krad.uif.view.View;
28
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
32
33
34
35
36
37
38
39
40
41
42
43
44 public class ViewCleaner {
45
46
47
48
49
50
51
52 public static void cleanView(View view) {
53 view.setApplicationHeader(null);
54 view.setApplicationFooter(null);
55 view.setNavigation(null);
56 view.setPage(null);
57 view.setViewMenuLink(null);
58 view.setClientSideState(new HashMap<String, Object>());
59 view.setViewTemplates(new ArrayList<String>());
60
61
62 PageGroup currentPage = view.getCurrentPage();
63
64 List<Component> pages = new ArrayList<Component>();
65 pages.add(currentPage);
66 view.setItems(pages);
67
68 cleanContainer(view);
69
70 view.getViewIndex().clearIndexesAfterRender();
71 }
72
73
74
75
76
77
78
79 public static void cleanCollectionGroup(CollectionGroup collectionGroup) {
80 collectionGroup.setAddLineLabel(null);
81 collectionGroup.setAddLineActions(new ArrayList<Action>());
82 collectionGroup.setLineActions(new ArrayList<Action>());
83 collectionGroup.setSubCollections(new ArrayList<CollectionGroup>());
84 collectionGroup.setActiveCollectionFilter(null);
85 collectionGroup.setFilters(new ArrayList<CollectionFilter>());
86
87 cleanContainer(collectionGroup);
88 }
89
90
91
92
93
94
95 public static void cleanContainer(Container container) {
96 container.setHeader(null);
97 container.setFooter(null);
98 container.setHelp(null);
99 container.setLayoutManager(null);
100 container.setInstructionalMessage(null);
101 container.setTemplateOptions(new HashMap<String, String>());
102 container.setComponentModifiers(new ArrayList<ComponentModifier>());
103 container.setPropertyReplacers(new ArrayList<PropertyReplacer>());
104 }
105
106
107
108
109
110
111 public static void cleanInputField(InputField inputField) {
112 inputField.setControl(null);
113 inputField.setInstructionalMessage(null);
114 inputField.setConstraintMessage(null);
115 inputField.setInquiry(null);
116 inputField.setLabel(null);
117 inputField.setTemplateOptions(new HashMap<String, String>());
118 inputField.setComponentModifiers(new ArrayList<ComponentModifier>());
119 inputField.setPropertyReplacers(new ArrayList<PropertyReplacer>());
120 }
121 }