KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.mmbase.bridge.jsp.taglib.util.Attribute;
13 import javax.servlet.jsp.JspTagException JavaDoc;
14
15 import org.mmbase.bridge.Node;
16 import org.mmbase.bridge.jsp.taglib.NodeReferrerTag;
17 import org.mmbase.util.logging.Logger;
18 import org.mmbase.util.logging.Logging;
19
20 /**
21  * To call the method createAlias from Node.
22  *
23  * @author Michiel Meeuwissen
24  * @version $Id: CreateAliasTag.java,v 1.9 2003/09/02 19:47:49 michiel Exp $
25  */

26
27 public class CreateAliasTag extends NodeReferrerTag {
28
29     private static final Logger log = Logging.getLoggerInstance(CreateAliasTag.class);
30
31     private Attribute alias = Attribute.NULL;
32
33     public void setName(String JavaDoc n) throws JspTagException JavaDoc {
34         alias = getAttribute(n);
35     }
36
37     protected void doJob(Node n, String JavaDoc a) {
38         log.debug("Creating alias '" + a + "' for node " + n.getNumber());
39         n.createAlias(a);
40     }
41
42     /**
43      * Add the alias.
44      *
45      * @todo I think doEndTag is not always called if no body!!
46      **/

47     public int doEndTag() throws JspTagException JavaDoc {
48         // search the node:
49
Node node = getNode();
50         
51         String JavaDoc a = alias.getString(this);
52         // alias name is in the body if no attribute name is given
53
if (a.equals("") && bodyContent != null) {
54             a = bodyContent.getString();
55         }
56         if (! "".equals(a)) {
57             doJob(node, a);
58         }
59         return EVAL_PAGE;
60     }
61 }
62
Popular Tags