KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > edit > CreateNodeTag


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.bridge.jsp.taglib.edit;
11
12 import javax.servlet.jsp.JspTagException JavaDoc;
13
14 import org.mmbase.bridge.*;
15 import org.mmbase.bridge.jsp.taglib.NodeTag;
16 import org.mmbase.bridge.jsp.taglib.util.Attribute;
17 import org.mmbase.util.logging.*;
18
19 /**
20  * A NodeProvider which creates a new node, which will be commited after the body. So, you
21  * can use `setField's in the body.
22  *
23  * @author Michiel Meeuwissen
24  * @version $Id: CreateNodeTag.java,v 1.22 2005/11/23 10:29:39 michiel Exp $
25  */

26
27 public class CreateNodeTag extends NodeTag {
28
29     private static final Logger log = Logging.getLoggerInstance(CreateNodeTag.class);
30
31     private Attribute nodeManager = Attribute.NULL;
32
33     public void setType(String JavaDoc t) throws JspTagException JavaDoc {
34         nodeManager = getAttribute(t);
35     }
36
37     public int doStartTag() throws JspTagException JavaDoc{
38         Cloud cloud = getCloudVar();
39         NodeManager nm = cloud.getNodeManager(nodeManager.getString(this));
40         if (nm == null) {
41             throw new JspTagException JavaDoc("Could not find nodemanager " + nodeManager.getString(this));
42         }
43         Node node = nm.createNode();
44         if (node == null) {
45             throw new JspTagException JavaDoc("Could not create node of type " + nm.getName());
46         }
47
48         setNodeVar(node);
49         fillVars();
50         return EVAL_BODY_BUFFERED;
51     }
52
53
54 }
55
Popular Tags