1 7 package com.inversoft.verge.util; 8 9 10 import javax.servlet.http.HttpServletRequest ; 11 import javax.servlet.jsp.PageContext ; 12 13 import com.inversoft.beans.BeanException; 14 import com.inversoft.beans.NestedBeanProperty; 15 import com.inversoft.util.typeconverter.TypeConversionException; 16 17 18 40 public class WebBeanProperty extends NestedBeanProperty { 41 42 protected WebBean webBean; 43 44 49 public WebBeanProperty() { 50 } 52 53 77 public WebBeanProperty(String definition, int scope, Class beanClass) 78 throws BeanException { 79 80 super(); 82 83 int index = definition.indexOf("."); 85 86 if (index == -1) { 87 throw new BeanException("Missing property name for the bean named: " + 88 definition); 89 } 90 91 webBean = new WebBean(definition.substring(0, index), scope, beanClass); 92 super.propertyName = definition.substring(index + 1); 93 super.beanClass = beanClass; 94 initialize(); 95 } 96 97 119 public WebBeanProperty(String propertyName, WebBean webBean) 120 throws BeanException { 121 122 super(propertyName, webBean.getBeanClass()); 124 this.webBean = webBean; 125 } 126 127 128 131 public WebBean getWebBean() { 132 return webBean; 133 } 134 135 138 public String getBeanName() { 139 return webBean.getID(); 140 } 141 142 147 public String getFullName() { 148 return webBean.getID() + "." + getPropertyName(); 149 } 150 151 152 public Object getPropertyValue(Object bean) throws BeanException { 153 throw new UnsupportedOperationException ("This method not implemented" + 154 " for the web bean property"); 155 } 156 157 158 public void setPropertyValue(Object bean, Object value, boolean convert) 159 throws BeanException { 160 throw new UnsupportedOperationException ("This method not implemented" + 161 " for the web bean property"); 162 } 163 164 165 public void setPropertyValue(final Object bean, Object value) { 166 throw new UnsupportedOperationException ("This method not implemented" + 167 " for the web bean property"); 168 } 169 170 181 public Object getPropertyValue(HttpServletRequest request) throws BeanException { 182 Object obj = webBean.getInstance(request); 183 return super.getPropertyValue(obj); 184 } 185 186 196 public Object getPropertyValue(PageContext context) throws BeanException { 197 Object obj = webBean.getInstance(context); 198 return super.getPropertyValue(obj); 199 } 200 201 216 public void setPropertyValue(HttpServletRequest request, Object value, 217 boolean convert) 218 throws BeanException, TypeConversionException { 219 Object obj = webBean.getInstance(request); 220 super.setPropertyValue(obj, value, convert); 221 } 222 223 243 public void setPropertyValue(HttpServletRequest request, Object value) 244 throws BeanException, TypeConversionException { 245 Object obj = webBean.getInstance(request); 246 super.setPropertyValue(obj, value, true); 247 } 248 249 263 public void setPropertyValue(PageContext context, Object value, 264 boolean convert) 265 throws BeanException, TypeConversionException { 266 Object obj = webBean.getInstance(context); 267 super.setPropertyValue(obj, value, convert); 268 } 269 } 270 | Popular Tags |