1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.preferences.web; |
18 | |
|
19 | |
import javax.servlet.http.HttpServletRequest; |
20 | |
|
21 | |
import org.kuali.rice.kew.preferences.Preferences; |
22 | |
import org.kuali.rice.kns.web.struts.form.KualiForm; |
23 | |
import org.kuali.rice.krad.exception.ValidationException; |
24 | |
import org.kuali.rice.krad.util.GlobalVariables; |
25 | |
import org.kuali.rice.krad.util.KRADConstants; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
public class PreferencesForm extends KualiForm { |
36 | |
|
37 | |
private static final long serialVersionUID = 4536869031291955777L; |
38 | |
private static final String ERR_KEY_REFRESH_RATE_WHOLE_NUM = "preferences.refreshRate"; |
39 | |
private static final String ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM = "preferences.pageSize"; |
40 | |
private Preferences preferences; |
41 | 0 | private String methodToCall = ""; |
42 | |
private String returnMapping; |
43 | 0 | private boolean showOutbox = true; |
44 | |
|
45 | |
|
46 | |
private String backLocation; |
47 | |
|
48 | |
public String getReturnMapping() { |
49 | 0 | return returnMapping; |
50 | |
} |
51 | |
public void setReturnMapping(String returnMapping) { |
52 | 0 | this.returnMapping = returnMapping; |
53 | 0 | } |
54 | 0 | public PreferencesForm() { |
55 | 0 | preferences = new Preferences(); |
56 | 0 | } |
57 | |
public String getMethodToCall() { |
58 | 0 | return methodToCall; |
59 | |
} |
60 | |
public void setMethodToCall(String methodToCall) { |
61 | 0 | this.methodToCall = methodToCall; |
62 | 0 | } |
63 | |
public Preferences getPreferences() { |
64 | 0 | return preferences; |
65 | |
} |
66 | |
public void setPreferences(Preferences preferences) { |
67 | 0 | this.preferences = preferences; |
68 | 0 | } |
69 | |
public boolean isShowOutbox() { |
70 | 0 | return this.showOutbox; |
71 | |
} |
72 | |
public void setShowOutbox(boolean showOutbox) { |
73 | 0 | this.showOutbox = showOutbox; |
74 | 0 | } |
75 | |
|
76 | |
public String getBackLocation() { |
77 | 0 | return this.backLocation; |
78 | |
} |
79 | |
public void setBackLocation(String backLocation) { |
80 | 0 | this.backLocation = backLocation; |
81 | 0 | } |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
@Override |
89 | |
public void populate(HttpServletRequest request) { |
90 | 0 | super.populate(request); |
91 | |
|
92 | 0 | if (getParameter(request, KRADConstants.RETURN_LOCATION_PARAMETER) != null) { |
93 | 0 | setBackLocation(getParameter(request, KRADConstants.RETURN_LOCATION_PARAMETER)); |
94 | |
} |
95 | 0 | } |
96 | |
|
97 | |
public void validatePreferences() { |
98 | |
|
99 | |
try { |
100 | 0 | new Integer(preferences.getRefreshRate().trim()); |
101 | 0 | } catch (NumberFormatException e) { |
102 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes"); |
103 | 0 | } catch (NullPointerException e1) { |
104 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes"); |
105 | 0 | } |
106 | |
|
107 | |
try { |
108 | 0 | new Integer(preferences.getPageSize().trim()); |
109 | 0 | if(new Integer(preferences.getPageSize().trim()) == 0){ |
110 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be non-zero "); |
111 | |
} |
112 | 0 | } catch (NumberFormatException e) { |
113 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be in whole minutes"); |
114 | 0 | } catch (NullPointerException e1) { |
115 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be in whole minutes"); |
116 | 0 | } |
117 | |
|
118 | 0 | if (GlobalVariables.getMessageMap().hasErrors()) { |
119 | 0 | throw new ValidationException("errors in preferences"); |
120 | |
} |
121 | 0 | } |
122 | |
} |