KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > taglib > IsWebEvent


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/IsWebEvent.java,v 1.10 2004/08/18 12:26:08 hkollmann Exp $
3  * $Revision: 1.10 $
4  * $Date: 2004/08/18 12:26:08 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.taglib;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import org.dbforms.event.WebEvent;
30
31 import org.dbforms.util.Util;
32
33 import javax.servlet.jsp.JspException JavaDoc;
34
35
36
37 /**
38  * DOCUMENT ME!
39  *
40  * @author $author$
41  * @version $Revision: 1.10 $
42  */

43 public class IsWebEvent extends DbBaseHandlerTag
44    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
45    // logging category for this class
46
private static Log logCat = LogFactory.getLog(IsWebEvent.class.getName());
47    private String JavaDoc event;
48    private String JavaDoc value;
49
50    /**
51     * Creates a new IsWebEvent object.
52     */

53    public IsWebEvent() {
54       value = "true";
55       event = null;
56    }
57
58    /**
59     * DOCUMENT ME!
60     *
61     * @param str DOCUMENT ME!
62     */

63    public final void setEvent(String JavaDoc str) {
64       event = str;
65    }
66
67
68    /**
69     * DOCUMENT ME!
70     *
71     * @param string
72     */

73    public void setValue(String JavaDoc string) {
74       value = string;
75    }
76
77
78    /**
79     * DOCUMENT ME!
80     *
81     * @return
82     */

83    public String JavaDoc getValue() {
84       return value;
85    }
86
87
88    /**
89     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
90     */

91    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
92       throw t;
93    }
94
95
96    /**
97     * DOCUMENT ME!
98     */

99    public void doFinally() {
100       value = "true";
101       event = null;
102       super.doFinally();
103    }
104
105
106    /**
107     * DOCUMENT ME!
108     *
109     * @return DOCUMENT ME!
110     *
111     * @throws JspException DOCUMENT ME!
112     */

113    public int doStartTag() throws JspException JavaDoc {
114       WebEvent we = getParentForm()
115                        .getWebEvent();
116
117       if ((we == null) || (event == null) || (value == null)) {
118          logCat.debug("Can't do IsWebEvent with webEvent: " + we + " event: "
119                       + event + " value: " + value);
120
121          return SKIP_BODY;
122       }
123
124       String JavaDoc className = we.getType();
125
126       boolean eventNameMatch = className.toUpperCase()
127                                         .indexOf(event.toUpperCase()) != -1;
128
129       if (logCat.isDebugEnabled()) {
130          logCat.debug(" IsLocalWebEvent webEvent className: " + className
131                       + " event: " + event + " value: " + value);
132       }
133
134       return (Util.getTrue(value) == eventNameMatch) ? EVAL_BODY_INCLUDE
135                                                      : SKIP_BODY;
136    }
137 }
138
Popular Tags