+ " AutoCompleteTextField to a parent form or container and"
+ " attach the parent to the Page before calling"
+ " getHeadElements().");
}
Context context = getContext();
if (headElements == null) {
headElements = super.getHeadElements();
String versionIndicator = ClickUtils.getResourceVersionIndicator(context);
headElements.add(new CssImport("/click/extras-control.css",
versionIndicator));
headElements.add(new JsImport("/click/control.js", versionIndicator));
headElements.add(new JsImport("/click/prototype/prototype.js",
versionIndicator));
headElements.add(new JsImport("/click/prototype/effects.js",
versionIndicator));
headElements.add(new JsImport("/click/prototype/controls.js",
versionIndicator));
}
// Note the addLoadEvent script is recreated and checked if it
// is contained in the headElement.
String fieldId = getId();
JsScript script = new JsScript();
script.setId(fieldId + "_autocomplete");
if (!headElements.contains(script)) {
// Script must be executed as soon as browser dom is ready
script.setExecuteOnDomReady(true);
String contextPath = context.getRequest().getContextPath();
HtmlStringBuffer buffer = new HtmlStringBuffer(150);
buffer.append("new Ajax.Autocompleter(");
buffer.append("'").append(fieldId).append("'");
buffer.append(",'").append(fieldId).append("_auto_complete_div'");
buffer.append(",'").append(contextPath).append(page.getPath()).append(