1 25 package org.ofbiz.webapp.taglib; 26 27 import java.io.IOException ; 28 import javax.servlet.jsp.JspException ; 29 import javax.servlet.jsp.JspWriter ; 30 import javax.servlet.jsp.tagext.TagSupport ; 31 32 import org.ofbiz.base.util.Debug; 33 import org.ofbiz.base.util.UtilJ2eeCompat; 34 35 42 public class PrintTag extends TagSupport { 43 44 public static final String module = PrintTag.class.getName(); 45 46 private String attribute = null; 47 private String defaultStr = ""; 48 49 public String getAttribute() { 50 return attribute; 51 } 52 53 public void setAttribute(String attribute) { 54 this.attribute = attribute; 55 } 56 57 public String getDefault() { 58 return defaultStr; 59 } 60 61 public void setDefault(String defaultStr) { 62 this.defaultStr = defaultStr; 63 } 64 65 public int doStartTag() throws JspException { 66 if (attribute == null) 67 return SKIP_BODY; 68 Object obj = pageContext.findAttribute(attribute); 69 70 if (obj == null) 71 obj = defaultStr; 72 73 try { 74 JspWriter out = pageContext.getOut(); 75 76 out.print(obj.toString()); 77 } catch (IOException e) { 78 if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) { 79 throw new JspException (e.getMessage(), e); 80 } else { 81 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module); 82 throw new JspException (e.toString()); 83 } 84 } 85 86 return SKIP_BODY; 87 } 88 } 89 90 | Popular Tags |