1 23 24 package org.infoglue.deliver.taglib.content; 25 26 import javax.servlet.jsp.JspException ; 27 import javax.servlet.jsp.JspTagException ; 28 29 import org.infoglue.deliver.taglib.component.ComponentLogicTag; 30 31 41 42 public class AssetUrlTag extends ComponentLogicTag 43 { 44 private static final long serialVersionUID = 3546080250652931383L; 45 46 private Integer contentId; 47 private String propertyName; 48 private String assetKey; 49 private boolean useInheritance = true; 50 51 public AssetUrlTag() 52 { 53 super(); 54 } 55 56 public int doEndTag() throws JspException 57 { 58 try 59 { 60 if(contentId != null) 61 { 62 if(assetKey != null) 63 produceResult(getController().getAssetUrl(contentId, assetKey)); 64 else 65 produceResult(getController().getAssetUrl(contentId)); 66 } 67 else if(propertyName != null) 68 { 69 if(assetKey != null) 70 produceResult(getComponentLogic().getAssetUrl(propertyName, assetKey, useInheritance)); 71 else 72 produceResult(getComponentLogic().getAssetUrl(propertyName, useInheritance)); 73 } 74 else 75 { 76 throw new JspException ("You must supply either contentId or propertyName"); 77 } 78 } 79 catch(Exception e) 80 { 81 throw new JspTagException ("ComponentLogic.getAssetUrl Error: " + e.getMessage()); 82 } 83 84 return EVAL_PAGE; 85 } 86 87 public void setAssetKey(String assetKey) 88 { 89 this.assetKey = assetKey; 90 } 91 92 public void setPropertyName(String propertyName) throws JspException 93 { 94 this.propertyName = evaluateString("assetUrl", "propertyName", propertyName); 95 } 96 97 public void setUseInheritance(boolean useInheritance) 98 { 99 this.useInheritance = useInheritance; 100 } 101 102 public void setContentId(String contentId) throws JspException 103 { 104 this.contentId = evaluateInteger("assetUrl", "contentId", contentId); 105 } 106 } | Popular Tags |