1 15 package org.apache.tapestry.bean; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.tapestry.IBeanProvider; 19 import org.apache.tapestry.IComponent; 20 import org.apache.tapestry.services.ExpressionEvaluator; 21 22 29 30 public class ExpressionBeanInitializer extends AbstractBeanInitializer 31 { 32 protected String _expression; 33 34 private final ExpressionEvaluator _evaluator; 35 36 public ExpressionBeanInitializer(ExpressionEvaluator evaluator) 37 { 38 _evaluator = evaluator; 39 } 40 41 public void setBeanProperty(IBeanProvider provider, Object bean) 42 { 43 IComponent component = provider.getComponent(); 44 45 try 46 { 47 Object value = _evaluator.read(component, _expression); 48 49 setBeanProperty(bean, value); 50 } 51 catch (Exception ex) 52 { 53 throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex); 54 } 55 } 56 57 58 59 public String getExpression() 60 { 61 return _expression; 62 } 63 64 65 66 public void setExpression(String expression) 67 { 68 _expression = expression; 69 } 70 71 } | Popular Tags |