1 7 package com.inversoft.verge.mvc.view.jsp.html; 8 9 10 import javax.servlet.jsp.JspException ; 11 12 import com.inversoft.util.StringTools; 13 import com.inversoft.verge.mvc.view.HtmlViewToolkit; 14 import com.inversoft.verge.mvc.view.jsp.JspTools; 15 16 17 35 public class BaseModelTag extends HtmlBaseTag { 36 37 private String model; 38 protected String localModel; 39 private Object value; 40 protected Object localValue; 41 protected boolean getValue = true; 42 protected boolean setValue = true; 43 protected String key; 44 protected String property; 45 46 47 52 public String getModel() { 53 return model; 54 } 55 56 61 public void setModel(String model) { 62 this.model = model; 63 } 64 65 70 public Object getValue() { 71 return value; 72 } 73 74 79 public void setValue(Object value) { 80 this.value = value; 81 } 82 83 96 public Object getLocalValue() { 97 return localValue; 98 } 99 100 105 public boolean isGetValue() { 106 return getValue; 107 } 108 109 114 public void setGetValue(boolean getValue) { 115 this.getValue = getValue; 116 } 117 118 123 public boolean isSetValue() { 124 return setValue; 125 } 126 127 132 public void setSetValue(boolean setValue) { 133 this.setValue = setValue; 134 } 135 136 144 protected void initialize() throws JspException { 145 super.initialize(); 146 147 localModel = model; 148 localValue = value; 149 150 if (!JspTools.JSP_20) { 152 localModel = (String ) JspTools.expand("model", model, String .class, 153 this, pageContext); 154 155 if (value instanceof String ) { 156 localValue = JspTools.expand("value", (String ) value, Object .class, 157 this, pageContext); 158 } 159 } 160 161 if (!hasName()) { 163 localName = HtmlViewToolkit.createUniqueName(); 164 } 165 } 166 167 172 protected void initializeKeyProperty() throws JspException { 173 int index = localModel.indexOf("."); 174 if (index == -1) { 175 throw new JspException ("Invalid model attribute: " + localModel + 176 ". The model attribute should contain a property definition"); 177 } 178 179 key = localModel.substring(0, index); 180 property = localModel.substring(index + 1); 181 if (StringTools.isEmpty(key) || StringTools.isEmpty(property)) { 182 throw new JspException ("Invalid model attribute '" + localModel + 183 "'. The model attribute should contain a bean and property " + 184 "definition"); 185 } 186 } 187 188 193 public void release() { 194 super.release(); setModel(null); 196 setValue(null); 197 setGetValue(true); 198 setSetValue(true); 199 } 200 } | Popular Tags |