1 package fr.improve.struts.taglib.layout.layer; 2 3 import javax.servlet.jsp.JspException ; 4 5 import fr.improve.struts.taglib.layout.LayoutTagSupport; 6 import fr.improve.struts.taglib.layout.collection.CollectionTag; 7 import fr.improve.struts.taglib.layout.el.Expression; 8 import fr.improve.struts.taglib.layout.util.LayoutUtils; 9 import fr.improve.struts.taglib.layout.util.ParentFinder; 10 11 17 public class LayerItemTag extends LayoutTagSupport { 18 19 private String name; 20 private String property; 21 private String key; 22 private String value; 23 private String JSPValue; 24 25 28 protected void initDynamicValues() { 29 JSPValue = value; 30 value = Expression.evaluate(value,pageContext); 31 super.initDynamicValues(); 32 } 33 34 37 protected void reset() { 38 value = JSPValue; 39 JSPValue = null; 40 } 41 42 45 public String getKey() { 46 return key; 47 } 48 51 public void setKey(String key) { 52 this.key = key; 53 } 54 57 public String getName() { 58 return name; 59 } 60 63 public void setName(String name) { 64 this.name = name; 65 } 66 69 public String getProperty() { 70 return property; 71 } 72 75 public void setProperty(String property) { 76 this.property = property; 77 } 78 81 public String getValue() { 82 return value; 83 } 84 87 public void setValue(String value) { 88 this.value = value; 89 } 90 protected Object buildContent() throws JspException { 91 Object lc_cell = null; 92 if (value!=null) { 93 return value; 94 } 95 if (name == null) { 96 CollectionTag collectionTag = (CollectionTag) ParentFinder.findLayoutTag(this, CollectionTag.class); 98 lc_cell = collectionTag.getBean(); 99 } else { 100 lc_cell = pageContext.findAttribute(name); 102 } 103 if (lc_cell != null && property != null) { 104 lc_cell = getPropertyValue(lc_cell, property); 106 } 107 return lc_cell; 108 } 109 110 114 protected Object getPropertyValue(Object in_bean, String in_property) throws JspException { 115 return LayoutUtils.getProperty(in_bean, in_property); 116 } 117 118 119 122 public int doEndLayoutTag() throws JspException { 123 124 return super.doEndLayoutTag(); 125 } 126 129 public int doStartLayoutTag() throws JspException { 130 StringBuffer results = new StringBuffer (""); 131 String lc_key = LayoutUtils.getLabel(pageContext,getKey(),null); 132 Object lc_contentObject = buildContent(); 133 String lc_content = lc_contentObject==null ? null : lc_contentObject.toString(); 134 135 if (lc_key!=null){ 136 results.append(lc_key); 137 } 138 if (lc_content!=null && lc_content.length()>0){ 139 results.append(lc_content); 140 } 141 LayerTag lc_layerTag = (LayerTag) ParentFinder.findLayoutTag(this, LayerTag.class); 142 lc_layerTag.addContent(results.toString()); 143 return (EVAL_BODY_INCLUDE); 144 } 145 146 } | Popular Tags |