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