KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > taglib > content > ContentVersionAttributeParameterTag


1 /* ===============================================================================
2 *
3 * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4 *
5 * ===============================================================================
6 *
7 * Copyright (C)
8 *
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 2, as published by the
11 * Free Software Foundation. See the file LICENSE.html for more information.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19 * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20 *
21 * ===============================================================================
22 */

23 package org.infoglue.deliver.taglib.content;
24
25 import javax.servlet.jsp.JspException JavaDoc;
26 import javax.servlet.jsp.JspTagException JavaDoc;
27
28 import org.infoglue.deliver.taglib.AbstractTag;
29
30 /**
31  * This class implements the <content:contentVersionAttributeParameter> tag, which adds a attributes
32  * to the list of attributes in the contentVersion.
33  *
34  * Note! This tag must have a <content:contentVersionParameter> ancestor.
35  */

36 public class ContentVersionAttributeParameterTag extends AbstractTag
37 {
38     /**
39      * The universal version identifier.
40      */

41     private static final long serialVersionUID = 4482006814634520239L;
42
43     /**
44      * The name of the parameter.
45      */

46     private String JavaDoc name;
47     
48     /**
49      * The value of the parameter.
50      */

51     private String JavaDoc value;
52     
53     /**
54      * Default constructor.
55      */

56     public ContentVersionAttributeParameterTag()
57     {
58         super();
59     }
60
61     /**
62      * Adds a parameter with the specified name and value to the parameters
63      * of the parent tag.
64      *
65      * @return indication of whether to continue evaluating the JSP page.
66      * @throws JspException if an error occurred while processing this tag.
67      */

68     public int doEndTag() throws JspException JavaDoc
69     {
70         addContentVersionAttribute();
71         return EVAL_PAGE;
72     }
73     
74     /**
75      * Adds the content version to the ancestor tag.
76      *
77      * @throws JspException if the ancestor tag isn't a url tag.
78      */

79     protected void addContentVersionAttribute() throws JspException JavaDoc
80     {
81         final ContentVersionParameterInterface parent = (ContentVersionParameterInterface) findAncestorWithClass(this, ContentVersionParameterInterface.class);
82         if(parent == null)
83         {
84             throw new JspTagException JavaDoc("ContentVersionAttributeParameterTag must have a ContentVersionParameterTag ancestor.");
85         }
86         ((ContentVersionParameterInterface) parent).addContentVersionAttribute(name, value);
87     }
88     
89     /**
90      * Sets the name attribute.
91      *
92      * @param name the name to use.
93      * @throws JspException if an error occurs while evaluating name parameter.
94      */

95     public void setName(final String JavaDoc name) throws JspException JavaDoc
96     {
97         this.name = evaluateString("parameter", "name", name);
98     }
99
100     /**
101      * Sets the value attribute.
102      *
103      * @param value the value to use.
104      * @throws JspException if an error occurs while evaluating value parameter.
105      */

106     public void setValue(final String JavaDoc value) throws JspException JavaDoc
107     {
108         this.value = evaluateString("parameter", "value", value);
109     }
110 }
111
Popular Tags