public class NoAutoCompleteEditRenderer
extends AbstractEditRenderer {
public void render(
Field field, DocumentFragment fragment,
RendererContext context, RendererContract contract)
throws ClientException, DataAccessException,
PlugInException {
String title = getTitle(field, context.getDataAccessor());
String targetID = context.addFormItem(field, title, null);
boolean useDefault = !"false".equalsIgnoreCase(
field.getParameters().get(FieldParameters.USE_DEFAULT));
String value = context.getFormItemInitialValue(
field, useDefault, null);
Element input = fragment.getOwnerDocument()
.createElement("input");
fragment.appendChild(input);
input.setAttribute("type", "text");
input.setAttribute("autocomplete", "no");
input.setAttribute("id", targetID);
input.setAttribute("name", targetID);
if (title != null && title.length() > 0) {
input.setAttribute("title", title);
}
if (value != null && value.length() > 0) {
input.setAttribute("value", value);
}
if ("true".equals(field.getParameters()
.get(FieldParameters.INITIAL_FOCUS))) {
input.setAttribute("tabindex", "1");
}
String width
= field.getParameters().get(FieldParameters.WIDTH);
if (width != null && width.length() > 0
&& !"0".equals(width)) {
String units;
if ("CHARS".equals(field.getParameters()
.get(FieldParameters.WIDTH_UNITS))) {
units = "em";
} else {
units = "%";
}
input.setAttribute("style", "width:" + width + units + ";");
}
setScriptAttributes(input, field);
}
}