1 15 package org.apache.tapestry.valid; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.hivemind.Location; 19 import org.apache.hivemind.lib.BeanFactory; 20 import org.apache.tapestry.IBinding; 21 import org.apache.tapestry.IComponent; 22 import org.apache.tapestry.binding.BindingFactory; 23 import org.apache.tapestry.coerce.ValueConverter; 24 25 33 public class ValidatorBindingFactory implements BindingFactory 34 { 35 private BeanFactory _validatorBeanFactory; 36 37 private ValueConverter _valueConverter; 38 39 public void setValidatorBeanFactory(BeanFactory validatorBeanFactory) 40 { 41 _validatorBeanFactory = validatorBeanFactory; 42 } 43 44 public void setValueConverter(ValueConverter valueConverter) 45 { 46 _valueConverter = valueConverter; 47 } 48 49 54 55 public IBinding createBinding(IComponent root, String bindingDescription, String path, 56 Location location) 57 { 58 try 59 { 60 IValidator validator = (IValidator) _validatorBeanFactory.get(path); 61 62 return new ValidatorBinding(bindingDescription, _valueConverter, location, validator); 63 } 64 catch (Exception ex) 65 { 66 throw new ApplicationRuntimeException(ex.getMessage(), location, ex); 67 } 68 } 69 70 } | Popular Tags |