1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.taglib;
25
26 import java.util.StringTokenizer;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31 import org.dbforms.event.AbstractWebEvent;
32
33 import org.dbforms.util.Util;
34
35 import javax.servlet.jsp.JspException;
36
37
38
39 /***
40 * DOCUMENT ME!
41 *
42 * @author $author$
43 * @version $Revision: 1.4 $
44 */
45 public class IsWebEventTag extends AbstractDbBaseHandlerTag
46 implements javax.servlet.jsp.tagext.TryCatchFinally {
47
48 private static Log logCat = LogFactory.getLog(IsWebEventTag.class.getName());
49 private String event;
50 private String value;
51
52 /***
53 * Creates a new IsWebEvent object.
54 */
55 public IsWebEventTag() {
56 value = "true";
57 event = null;
58 }
59
60 /***
61 * DOCUMENT ME!
62 *
63 * @param str DOCUMENT ME!
64 */
65 public final void setEvent(String str) {
66 event = str;
67 }
68
69
70 /***
71 * DOCUMENT ME!
72 *
73 * @param string
74 */
75 public void setValue(String string) {
76 value = string;
77 }
78
79
80 /***
81 * DOCUMENT ME!
82 *
83 * @return
84 */
85 public String getValue() {
86 return value;
87 }
88
89 /***
90 * DOCUMENT ME!
91 */
92 public void doFinally() {
93 value = "true";
94 event = null;
95 super.doFinally();
96 }
97
98
99 /***
100 * DOCUMENT ME!
101 *
102 * @return DOCUMENT ME!
103 *
104 * @throws JspException DOCUMENT ME!
105 */
106 public int doStartTag() throws JspException {
107 AbstractWebEvent we = getParentForm()
108 .getWebEvent();
109
110 if ((we == null) || (event == null) || (value == null)) {
111 logCat.debug("Can't do IsWebEvent with webEvent: " + we + " event: "
112 + event + " value: " + value);
113
114 return SKIP_BODY;
115 }
116
117 String className = we.getType();
118
119
120
121
122
123
124
125 boolean eventNameMatch = false;
126 StringTokenizer st = new StringTokenizer(event, ",");
127 while (st.hasMoreTokens()) {
128
129 String anEvent = st.nextToken().trim();
130 eventNameMatch = className.toUpperCase().indexOf(anEvent.toUpperCase()) != -1;
131 if (eventNameMatch == true) break;
132 }
133
134 if (logCat.isDebugEnabled()) {
135 logCat.debug(" IsLocalWebEvent webEvent className: " + className
136 + " event: " + event + " value: " + value);
137 }
138
139 return (Util.getTrue(value) == eventNameMatch) ? EVAL_BODY_INCLUDE
140 : SKIP_BODY;
141 }
142 }