bhak
10 Dec 2007, 8:41 PM
//snip
items: [
new Ext.form.ComboBox({
fieldLabel: 'Acquisition Type',
value: 'myVal',
id:'myComboList',
hiddenName: 'myCombo',
anchor:'95%',
typeAhead: false,
displayField:'name',
editable:true,
triggerAction: 'all',
lazyInit:false,
emptyText:'Select...',
store: getComboBoxDS()
})
]
Consider the case where the combobox consists of three values:
Apple
Orange
Pineapple
If a user selects any of those values, I'm able to read them via. on the server side when responding to a post: ie.
//Java sample...but issue is language-agnostic
String fruit = req.getParameter("myCombo");
will set fruit appropriately to "Apple", "Orange", or "Pineapple"
However, say instead of select an item from the dropdown, a user opts to enter, "Tomato". On the server-side, fruit won't get set to "Tomato".
Work-around:
I updated Ext-all.js to add an onBlur handler to ComboBox, and things are working for me now. FWIW, my onBlur handler just looks like the following:
onBlur : function(){
this.setValue(this.getValue());
},
this forces the combobox to set the value of it's backing hidden field, and everything posts as expected.
One question:
Rather than update ext-all.js directly, it seems like it would be better to just extend ComboBox and add my handler to the sub-class. Can somebody point me in the right direction to get started with sub-classing Ext components?
Cheers.
items: [
new Ext.form.ComboBox({
fieldLabel: 'Acquisition Type',
value: 'myVal',
id:'myComboList',
hiddenName: 'myCombo',
anchor:'95%',
typeAhead: false,
displayField:'name',
editable:true,
triggerAction: 'all',
lazyInit:false,
emptyText:'Select...',
store: getComboBoxDS()
})
]
Consider the case where the combobox consists of three values:
Apple
Orange
Pineapple
If a user selects any of those values, I'm able to read them via. on the server side when responding to a post: ie.
//Java sample...but issue is language-agnostic
String fruit = req.getParameter("myCombo");
will set fruit appropriately to "Apple", "Orange", or "Pineapple"
However, say instead of select an item from the dropdown, a user opts to enter, "Tomato". On the server-side, fruit won't get set to "Tomato".
Work-around:
I updated Ext-all.js to add an onBlur handler to ComboBox, and things are working for me now. FWIW, my onBlur handler just looks like the following:
onBlur : function(){
this.setValue(this.getValue());
},
this forces the combobox to set the value of it's backing hidden field, and everything posts as expected.
One question:
Rather than update ext-all.js directly, it seems like it would be better to just extend ComboBox and add my handler to the sub-class. Can somebody point me in the right direction to get started with sub-classing Ext components?
Cheers.