Richfaces.ComboBoxList.addMethods({ createDefaultList : function() { var items = new Array(); for (var i = 0; i < this.itemsText.length; i++) { // if itemsValue[] is defined, send also the custom value to this.createItem() if (this.itemsValue) items.push(this.createItem(this.itemsText[i], this.classes.item.normal, this.itemsValue[i])); else items.push(this.createItem(this.itemsText[i], this.classes.item.normal)); } this.createNewList(items); }, doSelectItem : function(item) { this.selectedItem = item; // Save selected item's value locally, which should be stored in the 'id' attribute of the 'span' tag if (item != null && item.id != null) this.selectedItemValue = item.id; }, getFilteredItems : function(text) { var items = new Array(); for (var i = 0; i < this.itemsText.length; i++) { var itText = this.itemsText[i]; if (itText.toLowerCase() .indexOf(text.toLowerCase()) != -1){ items.push(this.createItem(itText, this.classes.item.normal)); } } return items; }, findItemBySubstr : function(substr) { var items = this.getItems(); for ( var i = 0; i < items.length; i++) { var item = items[i] var itText = item.innerHTML.unescapeHTML(); if (itText.toLowerCase() .indexOf(substr.toLowerCase()) != -1){ return item; } } }, createItem : function(text, className, value) { // receive the custom value var escapedText = text.escapeHTML(); // Save custom value as 'id' in 'span', so it can be recovered later if (value != null) return "" + escapedText + ""; else return "" + escapedText + ""; } });