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
60
61 PageGroup currentPage = view.getCurrentPage();
62
63 List<Component> pages = new ArrayList<Component>();
64 pages.add(currentPage);
65 view.setItems(pages);
66
67 cleanContainer(view);
68
69 view.getViewIndex().clearIndexesAfterRender();
70 }
71
72
73
74
75
76
77
78 public static void cleanCollectionGroup(CollectionGroup collectionGroup) {
79 collectionGroup.setAddLineLabel(null);
80 collectionGroup.setAddLineActions(new ArrayList<Action>());
81 collectionGroup.setLineActions(new ArrayList<Action>());
82 collectionGroup.setSubCollections(new ArrayList<CollectionGroup>());
83 collectionGroup.setActiveCollectionFilter(null);
84 collectionGroup.setFilters(new ArrayList<CollectionFilter>());
85
86 cleanContainer(collectionGroup);
87 }
88
89
90
91
92
93
94 public static void cleanContainer(Container container) {
95 container.setHeader(null);
96 container.setFooter(null);
97 container.setHelp(null);
98 container.setLayoutManager(null);
99 container.setInstructionalMessage(null);
100 container.setTemplateOptions(new HashMap<String, String>());
101 container.setComponentModifiers(new ArrayList<ComponentModifier>());
102 container.setPropertyReplacers(new ArrayList<PropertyReplacer>());
103 }
104
105
106
107
108
109
110 public static void cleanInputField(InputField inputField) {
111 inputField.setControl(null);
112 inputField.setInstructionalMessage(null);
113 inputField.setConstraintMessage(null);
114 inputField.setInquiry(null);
115 inputField.setLabel(null);
116 inputField.setTemplateOptions(new HashMap<String, String>());
117 inputField.setComponentModifiers(new ArrayList<ComponentModifier>());
118 inputField.setPropertyReplacers(new ArrayList<PropertyReplacer>());
119 }
120 }