KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > panoptes > component > jmx > jelly > ContextEntryTag


1 /*
2  * Created on Aug 25, 2003
3  *
4  */

5 package net.sf.panoptes.component.jmx.jelly;
6
7 import org.apache.commons.jelly.JellyTagException;
8 import org.apache.commons.jelly.TagSupport;
9 import org.apache.commons.jelly.XMLOutput;
10
11 /**
12  *
13  *
14  * @author Dag Liodden
15  * @version 0.1
16  */

17 public class ContextEntryTag extends TagSupport {
18
19     private String JavaDoc name = null;
20     private Object JavaDoc value = null;
21
22     public void doTag(XMLOutput output) throws JellyTagException {
23         
24         NodeTag parent = (NodeTag) findAncestorWithClass(NodeTag.class);
25         if (parent == null)
26             throw new JellyTagException("This tag must be nested within <node> or descendant of <node>");
27         
28         if (name == null) throw new JellyTagException("Name is not set");
29         if (value == null) throw new JellyTagException("Value is not set");
30         parent.getNode().getContext().put(name, value);
31         getContext().setVariable(name, value);
32
33     }
34     
35     public void setName(String JavaDoc name) {
36         this.name = name;
37     }
38     
39     public void setValue(Object JavaDoc value) {
40         this.value = value;
41     }
42
43 }
44
Popular Tags