1 package org.infoglue.deliver.taglib.content; 2 3 import java.util.List ; 4 5 import javax.servlet.jsp.JspException ; 6 7 import org.infoglue.deliver.taglib.TemplateControllerTag; 8 9 public class RelatedContentsTag extends TemplateControllerTag { 10 13 private static final long serialVersionUID = 3761686771326530105L; 14 15 private Integer contentId; 16 private boolean onlyFirst; 17 private String attributeName; 18 19 public RelatedContentsTag() 20 { 21 super(); 22 } 23 24 public int doEndTag() throws JspException 25 { 26 produceResult(getRelatedContents()); 27 return EVAL_PAGE; 28 } 29 30 private Object getRelatedContents() throws JspException 31 { 32 final List related = getController().getRelatedContents(contentId, attributeName); 33 if(onlyFirst) 34 return related.isEmpty() ? null : related.get(0); 35 return related; 36 } 37 38 public void setContentId(String contentId) throws JspException 39 { 40 this.contentId = evaluateInteger("groupForContent", "contentId", contentId); 41 } 42 43 public void setOnlyFirst(boolean onlyFirst) 44 { 45 this.onlyFirst = onlyFirst; 46 } 47 48 public void setAttributeName(String attributeName) 49 { 50 this.attributeName = attributeName; 51 } 52 } 53 | Popular Tags |