1
2
3
4
5
6 package org.weda.tapestry.component;
7
8 import java.util.ArrayList;
9 import java.util.List;
10 import org.apache.commons.logging.Log;
11 import org.apache.commons.logging.LogFactory;
12 import org.apache.tapestry.BaseComponent;
13 import org.apache.tapestry.annotations.ComponentClass;
14 import org.apache.tapestry.annotations.InjectObject;
15 import org.apache.tapestry.annotations.Parameter;
16 import org.weda.Constants;
17 import org.weda.action.ActionRegistry;
18 import org.weda.action.ExecutedActionInfo;
19
20 /**Цель: показать ошибку возникшую при выолнение действия.
21 * @author Mikhail Titov
22 */
23 @ComponentClass(allowBody=false, allowInformalParameters=true)
24 public abstract class ActionError
25 extends BaseComponent
26 {
27 private final static Log log = LogFactory.getLog(ActionError.class);
28
29 public String errorMessage;
30
31 @Parameter(required=true)
32 public abstract ActionPanel getActionPanel();
33
34
35
36
37 public boolean hasError(){
38 ExecutedActionInfo info = getActionPanel().getExecutedActionInfo();
39 return info!=null && !info.isSuccessExecution();
40 }
41
42 public String getActionErrorClass(){
43 return Constants.ACTION_ERROR_CLASS;
44 }
45
46 public List<String> getErrorMessages(){
47 Throwable exception =
48 getActionPanel()
49 .getExecutedActionInfo()
50 .getExecutionException();
51 List<String> messages = new ArrayList<String>();
52 do {
53 messages.add(exception.getMessage());
54
55
56 } while((exception=exception.getCause())!=null);
57 return messages;
58 }
59 }