1 25 package org.ofbiz.webapp.taglib; 26 27 import java.io.IOException ; 28 import javax.servlet.jsp.JspException ; 29 import javax.servlet.jsp.tagext.TagSupport ; 30 31 import org.ofbiz.base.util.Debug; 32 import org.ofbiz.base.util.UtilJ2eeCompat; 33 import org.ofbiz.webapp.pseudotag.EntityField; 34 import org.ofbiz.entity.GenericEntityException; 35 36 44 public class EntityFieldTag extends TagSupport { 45 46 public static final String module = EntityFieldTag.class.getName(); 47 48 protected String field = null; 49 protected String type = null; 50 protected String attribute = null; 51 protected Object defaultObj = ""; 52 protected String prefix = null; 53 protected String suffix = null; 54 55 public String getAttribute() { 56 return attribute; 57 } 58 59 public void setAttribute(String attribute) { 60 this.attribute = attribute; 61 } 62 63 public String getField() { 64 return field; 65 } 66 67 public void setField(String field) { 68 this.field = field; 69 } 70 71 public String getType() { 72 return type; 73 } 74 75 public void setType(String type) { 76 this.type = type; 77 } 78 79 public String getPrefix() { 80 return prefix; 81 } 82 83 public void setPrefix(String prefix) { 84 this.prefix = prefix; 85 } 86 87 public String getSuffix() { 88 return suffix; 89 } 90 91 public void setSuffix(String suffix) { 92 this.suffix = suffix; 93 } 94 95 public Object getDefault() { 96 return defaultObj; 97 } 98 99 public void setDefault(Object defaultObj) { 100 this.defaultObj = defaultObj; 101 } 102 103 public int doStartTag() throws JspException { 104 try { 105 EntityField.run(attribute, field, prefix, suffix, defaultObj.toString(), type, pageContext); 106 } catch (IOException e) { 107 if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) { 108 throw new JspException (e.getMessage(), e); 109 } else { 110 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module); 111 throw new JspException (e.toString()); 112 } 113 } catch (GenericEntityException e) { 114 if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) { 115 throw new JspException ("Entity Engine error: " + e.getMessage(), e); 116 } else { 117 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module); 118 throw new JspException ("Entity Engine error: " + e.toString()); 119 } 120 } 121 122 return (SKIP_BODY); 123 } 124 } 125 | Popular Tags |