1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.web.taglib;
20
21 import org.apache.struts.Globals;
22 import org.apache.struts.action.ActionErrors;
23 import org.apache.struts.action.ActionMessage;
24 import org.apache.struts.action.ActionMessages;
25
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.jsp.JspException;
28 import javax.servlet.jsp.tagext.TagSupport;
29
30
31
32
33 @Deprecated
34 public final class AddErrorTag extends TagSupport {
35
36
37
38 private static final long serialVersionUID = 1L;
39 private String name = Globals.ERROR_KEY;
40 private String key;
41
42 public String getName() {
43 return name;
44 }
45
46 public void setName(String value) {
47 name = value;
48 }
49
50 public String getKey() {
51 return key;
52 }
53
54 public void setKey(String value) {
55 key = value;
56 }
57
58 public int doStartTag() throws JspException {
59 return (SKIP_BODY);
60 }
61
62 public int doEndTag() throws JspException {
63 ActionErrors errors = null;
64 HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
65
66 if (request == null || getKey() == null) {
67 return EVAL_PAGE;
68 }
69
70 try {
71 errors = (ActionErrors) request.getAttribute(getName());
72 } catch (ClassCastException cce) {
73 }
74
75 if (errors == null) {
76 errors = new ActionErrors();
77 }
78
79 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(getKey()));
80 request.setAttribute(getName(), errors);
81 clearState();
82 return EVAL_PAGE;
83 }
84
85 public void release() {
86 super.release();
87 clearState();
88 }
89
90 private void clearState() {
91 name = Globals.ERROR_KEY;
92 key = null;
93 }
94 }