……
17 public class TextboxComponent extends UIInput
implements CoveComponent {
……
20 public TextboxComponent(XulTextbox textbox) {
21 super();
22 xulTextbox = textbox;
23 setId(textbox.getId());
24 setup(textbox.getConfig());
25 }
……
……
35 private void setup(XulConfig xulConfig) {
36 ApplicationFactory aFactory =
37 (ApplicationFactory)FactoryFinder
.getFactory(FactoryFinder.APPLICATION_FACTORY);
38 Application application = aFactory.getApplication();
39 setupValidator(application, xulConfig);
40 setupConverter(application, xulConfig);
41 }
42
43 private void setupValidator(Application application,
XulConfig xulConfig) {
44 String validator = xulConfig.getValidatorAsString();
45 if ((validator == null) || ("".equals(validator))) return;
46 Class[] args = {FacesContext.class,
UIComponent.class,
Object.class};
47 MethodBinding methodBinding =
48 application.createMethodBinding(validator, args);
49 super.setValidator(methodBinding);
50 }
……
60 public void validate(FacesContext context) {
61 MethodBinding methodBinding = getValidator();
62 if (methodBinding == null) return;
63 Object[] values = {context, (UIComponent)this, getValue()};
64 try {
65 methodBinding.invoke(context, values);
66 } catch (ValidatorException e) {
67 setValid(false);
68 throw new ValidatorException(new FacesMessage(e.getMessage()));
69 }
70 }
……