1 23 24 package org.infoglue.deliver.taglib.common; 25 26 import java.util.Iterator ; 27 import java.util.List ; 28 29 import javax.servlet.jsp.JspException ; 30 31 import org.infoglue.cms.entities.content.ContentVO; 32 import org.infoglue.deliver.taglib.TemplateControllerTag; 33 34 public class IncludeTag extends TemplateControllerTag 35 { 36 private static final long serialVersionUID = 4050206323348354355L; 37 38 private Integer contentId; 39 private String relationAttributeName; 40 private String contentName; 41 private String template; 42 43 public IncludeTag() 44 { 45 super(); 46 } 47 48 public int doEndTag() throws JspException 49 { 50 try 51 { 52 if(contentId == null) 53 { 54 Integer componentContentId = this.getController().getComponentLogic().getInfoGlueComponent().getContentId(); 55 56 List relatedContents = this.getController().getRelatedContents(componentContentId, relationAttributeName); 57 58 Iterator i = relatedContents.iterator(); 59 while(i.hasNext()) 60 { 61 ContentVO contentVO = (ContentVO)i.next(); 62 if(contentVO.getName().equalsIgnoreCase(contentName)) 63 { 64 contentId = contentVO.getId(); 65 break; 66 } 67 } 68 69 template = this.getController().getContentAttribute(contentId, "Template"); 70 } 71 else 72 { 73 template = this.getController().getContentAttribute(contentId, "Template"); 74 } 75 76 String result = this.getController().renderString(template, false); 77 produceResult(result); 78 } 79 catch (Exception e) 80 { 81 e.printStackTrace(); 82 produceResult(""); 83 } 84 85 return EVAL_PAGE; 86 } 87 88 public void setTemplate(String template) throws JspException 89 { 90 this.contentId = null; 91 this.template = evaluateString("includeTag", "template", template); 92 } 93 94 public void setContentId(String contentId) throws JspException 95 { 96 this.contentId = evaluateInteger("includeTag", "contentId", contentId); 97 } 98 99 public void setRelationAttributeName(String relationAttributeName) throws JspException 100 { 101 this.contentId = null; 102 this.relationAttributeName = evaluateString("includeTag", "relationAttributeName", relationAttributeName); 103 } 104 105 public void setContentName(String contentName) throws JspException 106 { 107 this.contentId = null; 108 this.contentName = evaluateString("includeTag", "contentName", contentName); 109 } 110 } 111 | Popular Tags |