IFormComponent field,
Map symbols)
{
IEngine engine = field.getPage().getEngine();
IScriptSource source = engine.getScriptSource();
IForm form = field.getForm();
Map finalSymbols = (symbols == null) ? new HashMap() : symbols;
finalSymbols.put(FIELD_SYMBOL, field);
finalSymbols.put(FORM_SYMBOL, form);
finalSymbols.put(VALIDATOR_SYMBOL, this);
IResourceLocation location =
new ClasspathResourceLocation(engine.getResourceResolver(), scriptPath);
IScript script = source.getScript(location);
Body body = Body.get(cycle);
if (body == null)
throw new ApplicationRuntimeException(
Tapestry.getMessage("ValidField.must-be-contained-by-body"),
field,
null,
null);
script.execute(cycle, body, finalSymbols);
String functionName = (String) finalSymbols.get(FUNCTION_SYMBOL);
form.addEventHandler(FormEventType.SUBMIT, functionName);
}