-
1. Re: Change combobox suggestion value with javascript
ilya_shaikovsky Dec 15, 2009 6:14 AM (in response to rguillemette)Unfortunatelly no public api was designed. You could look through component scripts on your own to get possible extension points. And feel free to rise an issue.
B.t.w. this point already added to re-design comboBox documentation for 4.x
-
2. Re: Change combobox suggestion value with javascript
rguillemette Dec 15, 2009 6:37 AM (in response to ilya_shaikovsky)Thanks Ilya.
I will try to look into combobox javascript to add a convenient method.
Can I post my function here for others if I'm able to add such method?
@+
PS : the editor did not work with opera...this is annoying. Any way to disable it to use simple textarea?
-
3. Re: Change combobox suggestion value with javascript
ilya_shaikovsky Dec 15, 2009 7:08 AM (in response to rguillemette)About posting here - it would be great if you would post there or at wiki knowledgebase. Also you could rise an issue and submit patch there if will change component sources.
about forum comment there
-
4. Re: Change combobox suggestion value with javascript
rguillemette Dec 16, 2009 10:45 AM (in response to ilya_shaikovsky)Hello!
This is a quick solution I made.
These javascript function add 3 methods to Richfaces.ComboboxList object: add an item, delete an item and a simple indexOf on items list.
If you prefer to add these methods into Richfaces.Combobox object, feel free to change them, this is really simple...
The methods:
/** * addNewItem - Add new item. * @param val [string] new item to add. */ Richfaces.ComboBoxList.addMethods( { addItem : function(val) { this.itemsText.push(val); } }); /** * removeOldItem - Remove old item. * @param val [string | number] item's value or index to remove from the list. */ Richfaces.ComboBoxList.addMethods( { removeItem : function(val) { if (typeof val == "string") { // It's a value as string val = this.indexOf(val); // Get an position } if (val != -1) { this.itemsText.splice(val, 1); } } }); /** * indexOf - search item position. * You can use indexOf directly on comboList's itemsText. This is only a "quick access" method. * @param it [string] item's value to search. */ Richfaces.ComboBoxList.addMethods( { indexOf : function(it) { return this.itemsText.indexOf(it); } });
I also add another function to register a "pre-"function to be called before dataUpdating(). With this code, I was able to use combobox like a "syntax" suggestion input.
I don't have much time right now (I'm at work...) but I will try to add them to the wiki if you still want Ilya.
My god, I hate the new editor! :/ -
5. Re: Change combobox suggestion value with javascript
luiggitama Jul 3, 2010 5:53 AM (in response to rguillemette)Hi Remi, this is a great solution! It would be good if you share it as an article in RichFaces space and add it to the RichFaces KnowledgeBase.
I have also customized rich:comboBox from the client side, to make it support values as well as labels, and to make better suggestions based on a "contains any" criteria (not only "begins with"). Take a look at the article and tell me what you think!
Enhanced rich:comboBox: Values (not only Text) and RegExp Suggestions
God bless you.
Best regards,
Luis Tama