1 /***
2 * Copyright (c) 2003 held jointly by the individual authors.
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; with out even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * > http://www.gnu.org/copyleft/lesser.html
19 * > http://www.opensource.org/licenses/lgpl-license.php
20 */
21 package net.mlw.vlh.web.tag;
22
23 import java.util.HashMap;
24 import java.util.Map;
25
26 import javax.servlet.jsp.JspException;
27 import javax.servlet.jsp.tagext.BodyTagSupport;
28
29 import net.mlw.vlh.ValueList;
30 import net.mlw.vlh.web.tag.support.Attributeable;
31 import net.mlw.vlh.web.util.JspUtils;
32
33 /***
34 * @deprecated use action tag
35 * @author Matthew L. Wilson
36 * @version $Revision: 1.8 $ $Date: 2005/11/23 15:00:21 $
37 */
38 public class FilterTag extends BodyTagSupport implements Attributeable
39 {
40
41 private String url;
42
43 private Map parameters;
44
45 private ValueListSpaceTag rootTag;
46
47 /***
48 * @see javax.servlet.jsp.tagext.Tag#doStartTag()
49 */
50 public int doStartTag() throws JspException
51 {
52 rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
53
54 parameters = new HashMap(rootTag.getTableInfo().getParameters());
55 return super.doStartTag();
56 }
57
58 /***
59 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
60 */
61 public int doEndTag() throws JspException
62 {
63
64 ValueList valueList = rootTag.getValueList();
65
66 StringBuffer sb = new StringBuffer();
67 sb.append("<a href=\"").append(url);
68 sb.append(rootTag.getConfig().getLinkEncoder().encode(pageContext, parameters));
69 sb.append("\">");
70 sb.append(getBodyContent().getString());
71 sb.append("</a>");
72
73 JspUtils.write(pageContext, sb.toString());
74
75 release();
76
77 return EVAL_PAGE;
78 }
79
80 /***
81 * @see net.mlw.vlh.web.tag.support.Attributeable#setCellAttribute(java.lang.String, java.lang.String)
82 */
83 public void setCellAttribute(String name, String value)
84 {
85 parameters.put(name, value);
86 }
87
88 /***
89 * This tag will not append cell atributes, while they are used as link parameters !?
90 * @todo mathew removed this tag!
91 * @see net.mlw.vlh.web.tag.support.Attributeable#setCellAttribute(java.lang.String, java.lang.String)
92 */
93 public void appendClassCellAttribute(String name, String value)
94 {
95 parameters.put(name, value);
96 }
97
98 /***
99 * @param url The url to set.
100 */
101 public void setUrl(String url)
102 {
103 this.url = url;
104 }
105
106 private void reset()
107 {
108 this.rootTag = null;
109 this.parameters = null;
110 this.url = null;
111 }
112
113 /***
114 * Called on a Tag handler to release state.
115 * The page compiler guarantees that JSP page implementation
116 * objects will invoke this method on all tag handlers,
117 * but there may be multiple invocations on doStartTag and doEndTag in between.
118 *
119 * @see javax.servlet.jsp.tagext.Tag#release()
120 */
121 public void release()
122 {
123 super.release();
124 reset();
125 }
126 }