1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.util;
17
18 import org.apache.struts.action.ActionMessage;
19 import org.apache.struts.action.ActionMessages;
20 import org.kuali.rice.krad.util.ErrorMessage;
21
22 import java.util.ArrayList;
23
24
25
26
27
28
29
30 public class MessageList extends ArrayList<ErrorMessage> {
31 public void add(String messageKey, String... messageParameters) {
32 add(new ErrorMessage(messageKey, messageParameters));
33 }
34
35 public ActionMessages toActionMessages() {
36 ActionMessages actionMessages = new ActionMessages();
37 for (ErrorMessage errorMessage : this) {
38 actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(errorMessage.getErrorKey(), errorMessage.getMessageParameters()));
39 }
40 return actionMessages;
41 }
42 }