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.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.web.form.UifFormBase;
20
21 import java.io.Serializable;
22 import java.util.HashMap;
23 import java.util.Map;
24
25
26
27
28
29
30 public class UifFormManager implements Serializable {
31 private static final long serialVersionUID = -6323378881342207080L;
32
33 private UifFormBase currentForm;
34 private Map<String, UifFormBase> uifForms;
35
36 public UifFormManager() {
37 this.uifForms = new HashMap<String, UifFormBase>();
38 }
39
40 public UifFormBase getCurrentForm() {
41 return currentForm;
42 }
43
44 public void setCurrentForm(UifFormBase currentForm) {
45 this.currentForm = currentForm;
46 addForm(currentForm);
47 }
48
49 public void addForm(UifFormBase form) {
50 if (form == null) {
51 return;
52 }
53
54 uifForms.put(form.getFormKey(), form);
55 }
56
57 public UifFormBase getForm(String formKey) {
58 if (uifForms.containsKey(formKey)) {
59 return uifForms.get(formKey);
60 }
61
62 return null;
63 }
64
65 public void removeForm(UifFormBase form) {
66 if (form == null) {
67 return;
68 }
69
70 removeFormByKey(form.getFormKey());
71 }
72
73 public void removeFormByKey(String formKey) {
74 if (uifForms.containsKey(formKey)) {
75 uifForms.remove(formKey);
76 }
77
78 if ((currentForm != null) && StringUtils.equals(currentForm.getFormKey(), formKey)) {
79 currentForm = null;
80 }
81 }
82 }