1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.service.message;
35
36 import fr.paris.lutece.portal.service.i18n.I18nService;
37
38 import java.io.Serializable;
39
40 import java.text.MessageFormat;
41
42 import java.util.Locale;
43 import java.util.Map;
44
45
46
47
48 public class AdminMessage implements Serializable
49 {
50 public static final int TYPE_INFO = 0;
51 public static final int TYPE_QUESTION = 1;
52 public static final int TYPE_ERROR = 2;
53 public static final int TYPE_WARNING = 3;
54 public static final int TYPE_CONFIRMATION = 4;
55 public static final int TYPE_STOP = 5;
56 private static final long serialVersionUID = 1924932226627941151L;
57 private String _strTextKey;
58 private String _strTitleKey;
59 private String _strUrl;
60 private String _strTarget;
61 private int _nType;
62 private boolean _bCancel;
63 private Object [ ] _messageArgs;
64 private Map<String, Object> _requestParameters;
65 private String _strBackUrl;
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 public AdminMessage( String strTextKey, Object [ ] messageArgs, String strTitleKey, String strUrl, String strTarget, int nType, boolean bCancelButton )
86 {
87 buildAdminMessage( strTextKey, messageArgs, strTitleKey, strUrl, strTarget, nType, bCancelButton, null, null );
88 }
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 public AdminMessage( String strTextKey, Object [ ] messageArgs, String strTitleKey, String strUrl, String strTarget, int nType, boolean bCancelButton,
111 Map<String, Object> requestParameters )
112 {
113 buildAdminMessage( strTextKey, messageArgs, strTitleKey, strUrl, strTarget, nType, bCancelButton, requestParameters, null );
114 }
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 public AdminMessage( String strTextKey, Object [ ] messageArgs, String strTitleKey, String strUrl, String strTarget, int nType, boolean bCancelButton,
139 Map<String, Object> requestParameters, String strBackUrl )
140 {
141 buildAdminMessage( strTextKey, messageArgs, strTitleKey, strUrl, strTarget, nType, bCancelButton, requestParameters, strBackUrl );
142 }
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166 private void buildAdminMessage( String strTextKey, Object [ ] messageArgs, String strTitleKey, String strUrl, String strTarget, int nType,
167 boolean bCancelButton, Map<String, Object> requestParameters, String strBackUrl )
168 {
169 _strTextKey = strTextKey;
170 _strTitleKey = strTitleKey;
171 _strUrl = strUrl;
172 _strTarget = strTarget;
173 _nType = nType;
174 _bCancel = bCancelButton;
175 _messageArgs = messageArgs;
176 _requestParameters = requestParameters;
177 _strBackUrl = strBackUrl;
178 }
179
180
181
182
183
184
185 public int getType( )
186 {
187 return _nType;
188 }
189
190
191
192
193
194
195 public boolean isCancel( )
196 {
197 return _bCancel;
198 }
199
200
201
202
203
204
205
206 public void setCancel( boolean bCancel )
207 {
208 _bCancel = bCancel;
209 }
210
211
212
213
214
215
216
217
218 public String getText( Locale locale )
219 {
220 String strText = I18nService.getLocalizedString( _strTextKey, locale );
221
222 if ( _messageArgs != null )
223 {
224 strText = MessageFormat.format( strText, _messageArgs );
225 }
226
227 return strText;
228 }
229
230
231
232
233
234
235
236
237 public String getTitle( Locale locale )
238 {
239 return I18nService.getLocalizedString( _strTitleKey, locale );
240 }
241
242
243
244
245
246
247 public String getUrl( )
248 {
249 return _strUrl;
250 }
251
252
253
254
255
256
257 public String getTarget( )
258 {
259 return _strTarget;
260 }
261
262
263
264
265
266
267 public Map<String, Object> getRequestParameters( )
268 {
269 return _requestParameters;
270 }
271
272
273
274
275
276
277
278 public void setBackUrl( String strBackUrl )
279 {
280 this._strBackUrl = strBackUrl;
281 }
282
283
284
285
286
287 public String getBackUrl( )
288 {
289 return _strBackUrl;
290 }
291 }