KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > taglibs > Set


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.taglibs;
14
15 import info.magnolia.cms.core.Content;
16 import info.magnolia.cms.util.Resource;
17
18 import javax.jcr.RepositoryException;
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
21
22 import org.apache.log4j.Logger;
23
24
25 /**
26  * @author Sameer Charles
27  * @version $Revision: 929 $ ($Author: fgiust $)
28  */

29 public class Set extends TagSupport JavaDoc {
30
31     /**
32      * Stable serialVersionUID.
33      */

34     private static final long serialVersionUID = 222L;
35
36     /**
37      * Logger.
38      */

39     private static Logger log = Logger.getLogger(Set.class);
40
41     private transient Content contentNode;
42
43     private String JavaDoc contentNodeName;
44
45     /**
46      * @param contentNode to be set
47      */

48     public void setContentNode(Content contentNode) {
49         this.contentNode = contentNode;
50     }
51
52     /**
53      * @param name , contentNode name to be set
54      */

55     public void setContentNodeName(String JavaDoc name) {
56         this.contentNodeName = name;
57     }
58
59     /**
60      * @deprecated
61      */

62     public void setContainer(Content contentNode) {
63         this.setContentNode(contentNode);
64     }
65
66     /**
67      * @deprecated
68      */

69     public void setContainerName(String JavaDoc name) {
70         this.setContentNodeName(name);
71     }
72
73     /**
74      * @see javax.servlet.jsp.tagext.Tag#doStartTag()
75      */

76     public int doStartTag() {
77         HttpServletRequest JavaDoc req = (HttpServletRequest JavaDoc) pageContext.getRequest();
78         Resource.removeGlobalContentNode(req);
79         if (this.contentNodeName == null) {
80             Resource.setGlobalContentNode(req, this.contentNode);
81         }
82         else {
83             try {
84                 this.contentNode = Resource.getCurrentActivePage(req).getContent(this.contentNodeName);
85                 Resource.setGlobalContentNode(req, this.contentNode);
86             }
87             catch (RepositoryException re) {
88                 log.error(re.getMessage());
89             }
90         }
91         return SKIP_BODY;
92     }
93
94     /**
95      * @see javax.servlet.jsp.tagext.Tag#doEndTag()
96      */

97     public int doEndTag() {
98         return EVAL_PAGE;
99     }
100
101     /**
102      * @see javax.servlet.jsp.tagext.Tag#release()
103      */

104     public void release() {
105         super.release();
106         this.contentNode = null;
107         this.contentNodeName = null;
108     }
109 }
110
Popular Tags