Author: abelevich
Date: 2008-04-14 12:07:48 -0400 (Mon, 14 Apr 2008)
New Revision: 7809
Modified:
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js
trunk/ui/combobox/src/main/templates/combobox.jspx
Log:
http://jira.jboss.com/jira/browse/RF-3058
Modified:
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
---
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-14
16:02:38 UTC (rev 7808)
+++
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-14
16:07:48 UTC (rev 7809)
@@ -140,4 +140,8 @@
JSFunctionDefinition script = getUtils().getAsEventHandler(context, component,
attributeName, null);
return ScriptUtils.toScript(script);
}
+
+ public String encodeValue(String value){
+ return ScriptUtils.toScript(value);
+ }
}
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
---
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-04-14
16:02:38 UTC (rev 7808)
+++
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-04-14
16:07:48 UTC (rev 7809)
@@ -31,10 +31,13 @@
this.comboList = new Richfaces.ComboBoxList(listId, parentListId, selectFirstOnUpdate,
classes.COMBO_LIST, listWidth,
listHeight, itemsText, onlistcall, fieldId, shadowId, showDelay,
hideDelay);
this.defaultMessage = defaultMessage;
+ // TODO: should we move this logic to the template?
+ //
http://jira.jboss.com/jira/browse/RF-2956
if (value) {
var item = this.comboList.findItemBySubstr(value);
if (item) {
this.comboList.doSelectItem(item);
+ this.comboValue.value = item.innerHTML.unescapeHTML();
}
} else {
if (this.defaultMessage) {
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js
===================================================================
---
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js 2008-04-14
16:02:38 UTC (rev 7808)
+++
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js 2008-04-14
16:07:48 UTC (rev 7809)
@@ -79,7 +79,7 @@
if (this.selectedItem) {
//was created new item list, so necessary to recreate selectedItem
- this.doSelectItem(this.findItemBySubstr(this.selectedItem.innerHTML));
+ this.doSelectItem(this.findItemBySubstr(this.selectedItem.innerHTML.unescapeHTML()));
}
if (this.selectFirstOnUpdate) {
@@ -355,7 +355,7 @@
var items = this.getItems();
for (var i = 0; i < items.length; i++) {
var item = items[i]
- var itText = item.innerHTML;
+ var itText = item.innerHTML.unescapeHTML();
if (itText.substr(0, substr.length).toLowerCase() == substr.toLowerCase()) { //FIXME:
to optimaize
return item;
}
Modified: trunk/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/ui/combobox/src/main/templates/combobox.jspx 2008-04-14 16:02:38 UTC (rev 7808)
+++ trunk/ui/combobox/src/main/templates/combobox.jspx 2008-04-14 16:07:48 UTC (rev 7809)
@@ -89,9 +89,12 @@
value = getConvertedStringValue(context, component,value);
if ("".equals(value)) {
valueStyle = "rich-combobox-font-disabled";
- value = defaultLabel;
+ value = defaultLabel;
}
variables.setVariable("value", value);
+ String convertedValue = encodeValue((String)value);
+ variables.setVariable("convertedValue", convertedValue);
+
variables.setVariable("valueStyle", valueStyle);
Object inputStyle = component.getAttributes().get("inputStyle");
@@ -209,8 +212,8 @@
name="#{clientId}comboboxField"
disabled="#{disabled}"
class="#{valueStyle} rich-combobox-input-inactive
#{inputDisabledClass}" type="text"
+ readonly="#{enableManualInput}"
value="#{value}"
- readonly="#{enableManualInput}"
onblur="#{component.attributes['onblur']}"
style="width:#{correction}; #{inputStyle}"
autocomplete="off"
@@ -315,7 +318,7 @@
#{this:getAsEventHandler(context, component, "onlistcall")},
#{this:getAsEventHandler(context, component, "onselect")},
"#{defaultLabel}",
- #{disabled}, "#{value}",
+ #{disabled}, #{convertedValue},
#{component.attributes["showDelay"]},
#{component.attributes["hideDelay"]});
</script>
</div>