1 16 package org.apache.cocoon.forms.validation.impl; 17 18 import org.apache.avalon.framework.context.Context; 19 import org.apache.avalon.framework.context.ContextException; 20 import org.apache.avalon.framework.context.Contextualizable; 21 import org.apache.avalon.framework.thread.ThreadSafe; 22 import org.apache.cocoon.forms.formmodel.WidgetDefinition; 23 import org.apache.cocoon.forms.util.JavaScriptHelper; 24 import org.apache.cocoon.forms.validation.WidgetValidator; 25 import org.apache.cocoon.forms.validation.WidgetValidatorBuilder; 26 import org.mozilla.javascript.Function; 27 import org.w3c.dom.Element ; 28 29 36 public class JavaScriptValidatorBuilder 37 implements WidgetValidatorBuilder, Contextualizable, ThreadSafe { 38 39 private Context avalonContext; 40 41 private static final String [] ARG_NAMES = {"widget"}; 42 43 46 public void contextualize(Context context) throws ContextException { 47 this.avalonContext = context; 48 } 49 50 53 public WidgetValidator build(Element element, WidgetDefinition definition) throws Exception { 54 Function function = JavaScriptHelper.buildFunction(element, "validate", ARG_NAMES); 55 56 return new JavaScriptValidator(this.avalonContext, function); 57 } 58 } 59 | Popular Tags |