KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbRedirectURLTag.java,v 1.3 2004/08/18 12:26:08 hkollmann Exp $
3  * $Revision: 1.3 $
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 javax.servlet.http.HttpServletResponse JavaDoc;
30 import javax.servlet.jsp.JspException JavaDoc;
31
32
33
34 /**
35  * <p>
36  * the 3 examples below produce all the same result
37  * </p>
38  *
39  * <p>
40  * &lt;linkURL HREF="customer.jsp" table="customer" position="1:2:12-3:4:1992"
41  * /&gt;
42  * </p>
43  *
44  * <p>
45  * &lt;linkURL HREF="customer.jsp" table="customer" position="&lt;%= currentKey
46  * %&gt;" /&gt;
47  * </p>
48  *
49  * <p>
50  * &lt;linkURL HREF="customer.jsp" table="customer" /&gt; &lt;position
51  * fieldName="id" value="103" /&gt; &lt;position fieldName="cust_lang"
52  * value="2" /&gt; &lt;/linkURL&gt;
53  * </p>
54  *
55  * <p>
56  * result (off course without the line feeds)
57  * </p>
58  * <pre>/servlet/control?
59  * ac_goto_x=t&
60  * data_ac_goto_x_fu=/customer.jsp&
61  * data_ac_goto_x_destTable=17&
62  * data_ac_goto_x_destPos=103~2</pre>
63  *
64  * <p>
65  * Use it like this:
66  * </p>
67  * <pre><a HREF="&lt;linkURL HREF="customer.jsp" tableName="customer" position="103~2" /&gt;"> some text </a></pre>
68  *
69  * @author Neal Katz , based on work from Joachim Peer
70  */

71 public class DbRedirectURLTag extends DbLinkURLTag
72    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
73    private static Log logCat = LogFactory.getLog(DbRedirectURLTag.class.getName());
74
75    /**
76     * DOCUMENT ME!
77     *
78     * @return DOCUMENT ME!
79     *
80     * @throws JspException thrown when error occurs in processing the body of
81     * this method
82     */

83    public int doBodyEndTag() throws javax.servlet.jsp.JspException JavaDoc {
84       return super.doBodyEndTag();
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     * @return DOCUMENT ME!
100     *
101     * @throws JspException thrown when error occurs in processing the body of
102     * this method
103     */

104    public int doEndTag() throws javax.servlet.jsp.JspException JavaDoc {
105       try {
106          HttpServletResponse JavaDoc response = (HttpServletResponse JavaDoc) pageContext
107                                         .getResponse();
108          String JavaDoc s = makeUrl();
109          s = response.encodeURL(s);
110          response.sendRedirect(s);
111       } catch (java.io.IOException JavaDoc ioe) {
112          throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
113       } catch (Exception JavaDoc e) {
114          throw new JspException JavaDoc("Error: " + e.getMessage());
115       }
116
117       return SKIP_PAGE;
118    }
119
120
121    /**
122     * DOCUMENT ME!
123     */

124    public void doFinally() {
125       logCat.info("doFinally called");
126       super.doFinally();
127    }
128
129
130    // logging category for this class
131

132    /**
133     * DOCUMENT ME!
134     *
135     * @return DOCUMENT ME!
136     *
137     * @throws JspException thrown when error occurs in processing the body of
138     * this method
139     * @throws IllegalArgumentException thrown when some parameters are missing.
140     */

141    public int doStartTag() throws javax.servlet.jsp.JspException JavaDoc {
142       return super.doStartTag();
143    }
144 }
145
Popular Tags