results.append(functionName);
results.append(" () { \n");
for (Iterator x = form.getFields().iterator(); x.hasNext();)
{
Field field = (Field)x.next();
// Skip indexed fields for now until there is
// a good way to handle error messages (and the length
// of the list (could retrieve from scope?))
if (field.isIndexed()
|| field.getPage() != page
|| !field.isDependency(va.getName()))
{
continue;
}
String message =
Resources.getMessage(messages, locale, va, field);
message = (message != null) ? message : "";
//jscriptVar = this.getNextVar(jscriptVar);
results.append(" this.a");
results.append(jscriptVar++);
results.append(" = new Array(\"");
results.append(field.getKey()); // TODO: escape?
results.append("\", \"");
results.append(escapeJavascript(message));
results.append("\", ");
results.append("new Function (\"varName\", \"");
Map vars = field.getVars();
// Loop through the field's variables.
Iterator varsIterator = vars.keySet().iterator();
while (varsIterator.hasNext())
{
String varName = (String)varsIterator.next(); // TODO: escape?