// If some other field has taken the honors, then let it.
if (cycle.getAttribute(SELECTED_ATTRIBUTE_NAME) != null)
return;
Body body = Body.get(cycle);
// If not wrapped by a Body, then do nothing.
if (body == null)
return;
IForm form = Form.get(cycle);
String formName = form.getName();
String textFieldName = getName();
String fullName = "document." + formName + "." + textFieldName;
body.addInitializationScript(fullName + ".focus();");
body.addInitializationScript(fullName + ".select();");
// Put a marker in, indicating that the selected field is known.
cycle.setAttribute(SELECTED_ATTRIBUTE_NAME, Boolean.TRUE);
}