KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > community > taglib > GetInfoTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.applications.community.taglib;
11
12 import org.mmbase.bridge.jsp.taglib.util.Attribute;
13
14 import javax.servlet.jsp.JspTagException JavaDoc;
15 import javax.servlet.jsp.JspException JavaDoc;
16
17
18 import org.mmbase.bridge.Node;
19
20 import org.mmbase.bridge.jsp.taglib.*;
21
22 /**
23  * GetInfo tag obtains information from the multipurpose INFO field.
24  *
25  * @author Pierre van Rooden
26  * @author Michiel Meeuwissen
27  * @version $Id: GetInfoTag.java,v 1.16 2005/01/30 16:46:35 nico Exp $
28  */

29  
30 public class GetInfoTag extends NodeReferrerTag implements Writer {
31
32     private Attribute key = Attribute.NULL;
33     public void setKey(String JavaDoc k) throws JspTagException JavaDoc {
34         key = getAttribute(k);
35     }
36
37
38     public int doStartTag() throws JspTagException JavaDoc{
39         // firstly, search the node:
40
Node node = getNode();
41
42         String JavaDoc k;
43         // found the node now. Now we can decide what must be shown:
44
if (key == Attribute.NULL) {
45             k = "name";
46         } else {
47             k = key.getString(this);
48         }
49         String JavaDoc value = node.getStringValue("getinfovalue(" + k + ")");
50         if (value == null) value = "";
51         
52         helper.setValue(value);
53         helper.useEscaper(false); // fieldinfo typicaly produces xhtml
54
if (getId() != null) {
55             getContextProvider().getContextContainer().register(getId(), helper.getValue());
56         }
57         return EVAL_BODY_BUFFERED;
58     }
59
60
61     /**
62      * write the value of the field.
63      **/

64     public int doEndTag() throws JspTagException JavaDoc {
65         return helper.doEndTag();
66     }
67
68     public int doAfterBody() throws JspException JavaDoc {
69         return helper.doAfterBody();
70     }
71 }
72
Popular Tags