1 16 package org.apache.cocoon.woody.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.woody.formmodel.WidgetDefinition; 23 import org.apache.cocoon.woody.util.JavaScriptHelper; 24 import org.apache.cocoon.woody.validation.WidgetValidator; 25 import org.apache.cocoon.woody.validation.WidgetValidatorBuilder; 26 import org.mozilla.javascript.Function; 27 import org.w3c.dom.Element ; 28 29 36 public class JavaScriptValidatorBuilder implements WidgetValidatorBuilder, Contextualizable, ThreadSafe { 37 38 private Context avalonContext; 39 40 private static final String [] ARG_NAMES = {"widget"}; 41 42 45 public void contextualize(Context context) throws ContextException { 46 this.avalonContext = context; 47 } 48 49 52 public WidgetValidator build(Element element, WidgetDefinition definition) throws Exception { 53 Function function = JavaScriptHelper.buildFunction(element, ARG_NAMES); 54 55 return new JavaScriptValidator(this.avalonContext, function); 56 } 57 } 58 | Popular Tags |