1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.util; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.Iterator; |
20 | |
import java.util.List; |
21 | |
import java.util.Set; |
22 | |
|
23 | |
import org.apache.struts.action.ActionMessage; |
24 | |
import org.apache.struts.action.ActionMessages; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public abstract class MessageContainer implements Serializable { |
33 | |
private MessageMap errorMap; |
34 | |
|
35 | 0 | protected MessageContainer(MessageMap errorMap) { |
36 | 0 | this.errorMap = errorMap; |
37 | 0 | } |
38 | |
|
39 | |
protected MessageMap getMessageMap() { |
40 | 0 | return errorMap; |
41 | |
} |
42 | |
|
43 | |
public ActionMessages getRequestMessages() { |
44 | 0 | ActionMessages requestErrors = new ActionMessages(); |
45 | 0 | for (Iterator<String> iter = getMessagePropertyNames().iterator(); iter.hasNext();) { |
46 | 0 | String property = iter.next(); |
47 | 0 | List errorList = (List) getMessagesForProperty(property); |
48 | |
|
49 | 0 | for (Iterator iterator = errorList.iterator(); iterator.hasNext();) { |
50 | 0 | ErrorMessage errorMessage = (ErrorMessage) iterator.next(); |
51 | |
|
52 | |
|
53 | 0 | requestErrors.add(property, new ActionMessage(errorMessage.getErrorKey(), errorMessage.getMessageParameters())); |
54 | 0 | } |
55 | 0 | } |
56 | 0 | return requestErrors; |
57 | |
} |
58 | |
|
59 | |
public abstract int getMessageCount(); |
60 | |
|
61 | |
public abstract List<String> getMessagePropertyList(); |
62 | |
|
63 | |
protected abstract Set<String> getMessagePropertyNames(); |
64 | |
|
65 | |
protected abstract List getMessagesForProperty(String propertyName); |
66 | |
} |