protected int getItemPresentationColumn(DropDownComponent dropDown) {
return -1;
}
protected InitScript renderInitScript(FacesContext context, DropDownComponent dropDown) throws IOException {
DropDownFieldBase dropDownField = (DropDownFieldBase) dropDown;
DropDownPopup popup = dropDownField.getPopup();
ScriptBuilder buf = new ScriptBuilder();
TableStructure tableStructure = popup.getChildData().getTableStructure();
buf.initScript(context, dropDownField, "O$.DropDownField._init",
dropDownField.getTimeout(),
dropDownField.getListAlignment(),
Styles.getStyleClassesStr(context, dropDownField, dropDownField.getRolloverListItemStyle(),
dropDownField.getRolloverListItemClass(), DefaultStyles.getDefaultSelectionStyle(), StyleGroup.rolloverStyleGroup()),
getItemValuesArray(getItemValues(dropDown)),
dropDownField.getCustomValueAllowed(),
dropDownField.isRequired(),
dropDownField.getSuggestionMode(),
dropDownField.getSuggestionDelay(),
dropDownField.getSuggestionMinChars(),
isManualListOpeningAllowed(dropDownField),
dropDownField.getAutoComplete(),
dropDownField.getAttributes().get(ATTR_TOTAL_ITEM_COUNT),
dropDownField.getAttributes().get(ATTR_PAGE_SIZE),
tableStructure.getInitParam(context, POPUP_TABLE_DEFAULT_STYLES),
dropDownField.isCachingAllowed(),
getItemPresentationColumn(dropDown),
dropDownField.getChangeValueOnSelect()
);
popup.resetChildData();
if (!dropDown.isReadonly()) {
Map<String, Script> eventHandlers = new HashMap<String, Script>();
String onchange = dropDownField.getOnchange();
if (onchange != null)
eventHandlers.put("onchange_adapted", new AnonymousFunction(new RawScript(onchange), "event"));
String onkeypress = dropDownField.getOnkeypress();
if (onkeypress != null)
eventHandlers.put("onkeypress_adapted", new AnonymousFunction(new RawScript(onkeypress), "event"));
String ondropdown = dropDownField.getOndropdown();
if (ondropdown != null)
eventHandlers.put("ondropdown", new AnonymousFunction(new RawScript(ondropdown), "event"));
String oncloseup = dropDownField.getOncloseup();
if (oncloseup != null)
eventHandlers.put("oncloseup", new AnonymousFunction(new RawScript(oncloseup), "event"));
buf.O$(dropDownField).dot().functionCall("_setCustomEvents", eventHandlers).semicolon();
}