1 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 ; 20 import javax.servlet.jsp.tagext.TagSupport ; 21 22 import org.apache.log4j.Logger; 23 24 25 29 public class Set extends TagSupport { 30 31 34 private static final long serialVersionUID = 222L; 35 36 39 private static Logger log = Logger.getLogger(Set.class); 40 41 private transient Content contentNode; 42 43 private String contentNodeName; 44 45 48 public void setContentNode(Content contentNode) { 49 this.contentNode = contentNode; 50 } 51 52 55 public void setContentNodeName(String name) { 56 this.contentNodeName = name; 57 } 58 59 62 public void setContainer(Content contentNode) { 63 this.setContentNode(contentNode); 64 } 65 66 69 public void setContainerName(String name) { 70 this.setContentNodeName(name); 71 } 72 73 76 public int doStartTag() { 77 HttpServletRequest req = (HttpServletRequest ) 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 97 public int doEndTag() { 98 return EVAL_PAGE; 99 } 100 101 104 public void release() { 105 super.release(); 106 this.contentNode = null; 107 this.contentNodeName = null; 108 } 109 } 110 | Popular Tags |