Author: pyaschenko
Date: 2008-03-13 11:44:45 -0400 (Thu, 13 Mar 2008)
New Revision: 6785
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
RF-1774
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
---
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-13
15:17:34 UTC (rev 6784)
+++
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-13
15:44:45 UTC (rev 6785)
@@ -721,7 +721,7 @@
for (var i=0;i<items.length;i++)
{
itm = this.selectedItemsCache[items[i]];
- if (!itm) itm = {text:items[i], object: undefined};
+ if (!itm) itm = {text:items[i], object: null};
this.selectedItems.push(itm);
newItemsCache[itm.text] = itm;
}
@@ -729,12 +729,38 @@
else
{
itm = this.selectedItemsCache[value];
- if (!itm) itm = {text:items[i], object: undefined};
+ if (!itm) itm = {text:items[i], object: null};
this.selectedItems.push(itm);
newItemsCache[itm.text] = itm;
}
this.selectedItemsCache = newItemsCache;
},
+
+ updateSelectedItems: function (items)
+ {
+ for (var i=0;i<this.selectedItems.length; i++)
+ {
+ var obj = items[this.selectedItems.text];
+ if (obj) this.selectedItems.object = obj;
+ }
+ },
+
+ getItemListForUpdate: function()
+ {
+ var list = [];
+ var result="";
+ if (this.options.tokens.length!=0)
+ {
+ for (var i=0;i<this.selectedItems.length; i++)
+ {
+ if (!this.selectedItems.object) list.push(this.selectedItems.text);
+ }
+ result = list.join(this.options.tokens[0]);
+ }
+ else if (this.selectedItems.length!=0 && !this.selectedItems[0].object)
result = this.selectedItems.object;
+
+ return result;
+ },
insertValue: function(value)
{
@@ -796,8 +822,8 @@
getUpdatedChoices: function(event) {
this.options.parameters[this.options.param] = this.getToken();
- // TODO add string list parameter for the values that need object from server
-
+ // TODO-done: add string list parameter for the values that need object from server
+ this.options.parameters["inputvaluerequest"] =
this.getItemListForUpdate();
if (this.onsubmitFunction && ! this.onsubmitFunction()) {
return;
}
@@ -814,8 +840,9 @@
RichFaces.Position.smartClone(this.element, this.update, this.options);
}
this.updateChoices();
- this.fetchValues = data;
- // TODO add update item objects from data
+ this.fetchValues = data; // use data.suggestionObjects
+ // TODO-done: add update item objects from data
+ this.updateSelectedItems(data); // use data.requestedObjects
LOG.debug("Choices updated");
if (this.options.onajaxcomplete) {
this.options.onajaxcomplete(request, event);
Show replies by date