1 25 package org.ofbiz.webapp.taglib; 26 27 import javax.servlet.jsp.JspTagException ; 28 import javax.servlet.jsp.tagext.TagSupport ; 29 30 import org.ofbiz.base.util.Debug; 31 import org.ofbiz.base.util.ObjectType; 32 import org.ofbiz.base.util.UtilValidate; 33 34 41 public class ObjectTag extends TagSupport { 42 43 public static final String module = ObjectTag.class.getName(); 44 45 protected Object element = null; 46 protected String name = null; 47 protected String property = null; 48 protected Class type = null; 49 50 public void setName(String name) { 51 this.name = name; 52 } 53 54 public void setProperty(String property) { 55 this.property = property; 56 } 57 58 public void setType(String type) throws ClassNotFoundException { 59 this.type = ObjectType.loadClass(type); 60 } 61 62 public String getName() { 63 return name; 64 } 65 66 public String getProperty() { 67 return property; 68 } 69 70 public Object getObject() { 71 return element; 72 } 73 74 public String getType() { 75 return type.getName(); 76 } 77 78 public int doStartTag() throws JspTagException { 79 String realAttrName = property; 80 81 if (UtilValidate.isEmpty(realAttrName)) { 82 realAttrName = name; 83 } 84 element = pageContext.findAttribute(realAttrName); 85 if (element != null) { 86 pageContext.setAttribute(name, element); 87 } else { 88 Debug.logWarning("Did not find element in property. (" + property + ")", module); 89 } 90 return EVAL_BODY_INCLUDE; 91 } 92 93 public int doEndTag() { 94 return EVAL_PAGE; 95 } 96 } 97 98 | Popular Tags |