Author: abelevich
Date: 2009-07-08 12:54:52 -0400 (Wed, 08 Jul 2009)
New Revision: 14855
Modified:
branches/enterprise/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
branches/enterprise/3.3.X/ui/combobox/src/main/templates/combobox.jspx
Log:
https://jira.jboss.org/jira/browse/RF-7286
Modified:
branches/enterprise/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
---
branches/enterprise/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2009-07-08
15:38:28 UTC (rev 14854)
+++
branches/enterprise/3.3.X/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2009-07-08
16:54:52 UTC (rev 14855)
@@ -7,7 +7,7 @@
initialize: function(combobox, listId, parentListId, valueFieldId, fieldId, buttonId,
buttonBGId, shadowId, commonStyles, userStyles,
listWidth, listHeight, itemsText, directInputSuggestions, filterNewValue,
selectFirstOnUpdate, onlistcall, onlistclose, onselected, defaultMessage,
isDisabled, value,
- showDelay, hideDelay) {
+ showDelay, hideDelay, onchange) {
this.directInputSuggestions = directInputSuggestions;
this.filterNewValue = filterNewValue;
@@ -51,6 +51,7 @@
if (this.onselected) {
this.combobox.observe("rich:onselect", this.onselected);
}
+ this.onchange = onchange;
if (this.isDisabled) {
this.disable(); //TODO rename to 'disable'
}
@@ -296,6 +297,7 @@
}
}
this.comboList.hideWithDelay();
+ this.setValue(false);
} else {
this.doActive();
}
@@ -330,12 +332,32 @@
}
if (this.isValueSet(event) && isSearchSuccessful) {
- this.setValue();
+ var value = this.getActiveItemValue();
+ if(value && this.directInputSuggestions) {
+ this.doDirectSuggestion(value);
+ }
}
+
this.comboValue.value = this.field.value;
}
},
+ getActiveItemValue: function(){
+ var value;
+ if (this.comboList.activeItem) {
+ value = jQuery(this.comboList.activeItem).text();
+ value = value.replace(/\xA0/g," ").strip();
+ }
+ return value;
+ },
+
+ doDirectSuggestion: function(value) {
+ var startInd = this.field.value.length;
+ var endInd = value.length;
+ this.field.value = value;
+ Richfaces.ComboBox.textboxSelect(this.field, startInd, endInd);
+ },
+
wasTextDeleted : function(event) {
if ((event.keyCode == Event.KEY_BACKSPACE)
|| (event.keyCode == Event.KEY_DELETE)
@@ -364,33 +386,23 @@
},
setValue : function(toSetOnly) {
- if (!this.comboList.activeItem) {
- return;
- }
-
- var value = jQuery(this.comboList.activeItem).text();
-
- if (toSetOnly) {
- var oV = this.field.value;
- if (oV == value) {
- if (Prototype.Browser.Gecko) {
- this.field.value = "";
- this.comboValue.value = "";
- }
- }
- this.field.prevValue = value;
- this.field.value = value;
+
+ var value = this.getActiveItemValue();
+ if(value && toSetOnly) {
this.comboValue.value = value;
this.comboList.doSelectItem(this.comboList.activeItem);
this.combobox.fire("rich:onselect", {});
- } else {
- if (this.directInputSuggestions) {
- var startInd = this.field.value.length;
- var endInd = value.length;
- this.field.value = value;
- Richfaces.ComboBox.textboxSelect(this.field, startInd, endInd);
- }
}
+
+
+ var newValue = this.comboValue.value;
+ var oldValue = this.field.prevValue;
+
+ if(newValue && (newValue != oldValue)) {
+ this.field.prevValue = newValue;
+ this.field.value = newValue;
+ Richfaces.invokeEvent(this.onchange, this.combobox, "onchange",
{value:newValue});
+ }
},
applyDefaultText : function() {
Modified: branches/enterprise/3.3.X/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- branches/enterprise/3.3.X/ui/combobox/src/main/templates/combobox.jspx 2009-07-08
15:38:28 UTC (rev 14854)
+++ branches/enterprise/3.3.X/ui/combobox/src/main/templates/combobox.jspx 2009-07-08
16:54:52 UTC (rev 14855)
@@ -217,7 +217,6 @@
value="#{value}"
x:onblur="#{component.attributes['onblur']}"
onfocus = "#{component.attributes['onfocus']}"
- onchange = "#{component.attributes['onchange']}"
style="width:#{correction}; #{inputInactiveStyle}"
autocomplete="off"
tabindex="#{component.attributes['tabindex']}"
@@ -360,7 +359,7 @@
#{this:getAsEventHandler(context, component, "onselect")},
"#{defaultLabel}",
#{disabled}, #{convertedValue},
- #{component.attributes["showDelay"]},
#{component.attributes["hideDelay"]});
+ #{component.attributes["showDelay"]},
#{component.attributes["hideDelay"]}, #{this:getAsEventHandler(context,
component, "onchange")});
</script>
</div>
</f:root>