All,
I am getting a cast exception when attempting to create a new record via a POST using Extjs' JSONStore. The exception happens when an empty string is passed to the server and the server attempts to convert it into an Integer. The comboBox's valueField is set to an int defined field. The datastore fields are as follows:
fields: [
{ name: 'id', type: 'int' },
{ name: 'displayOrder', mapping: 'displayOrder', type: 'int' },
{ name: 'displayName', mapping: 'displayName', type: 'string' },
{ name: 'enabled', mapping: 'enabled', type: 'boolean' },
{ name: 'letterCode', mapping: 'letterCode', type: 'string' }
],
the combobox definition is:
{
xtype: 'combo',
id:"secondaryIncidentCombo",
hiddenName: 'secondaryIncidentTypeId',
forceSelection: true,
width:"200",
selectOnFocus: true,
emptyText: 'Secondary Incident',
editable: false,
mode: 'local',
displayField: 'displayName',
valueField: 'id',
store: this.secondaryIncidentTypeArrayStore,
triggerAction: 'all'
},
The JSONStore used to send the POST is, oddly enough, sending the value of the combobox as an empty string, even though I've configured the JSONWriter not to send unchanged fields:
writer: new Ext.data.JsonWriter({
encode: false,
writeAllFields:false
}),
And the POST value sent to the server: ....,"secondaryIncidentTypeId":"",... <-- notice the empty string after the colon.
Here is the secondaryIncidentTypeArrayStore:
secondaryIncidentTypeArrayStore: new Ext.data.ArrayStore({
idProperty: 'id',
fields: [
{ name: 'id', mapping: 'id', type: 'int' },
{ name: 'displayOrder', mapping: 'displayOrder', type: 'int' },
{ name: 'displayName', mapping: 'displayName', type: 'string' },
{ name: 'enabled', mapping: 'enabled', type: 'boolean' },
{ name: 'letterCode', mapping: 'letterCode', type: 'string' }
],
data: []
})
I'm on the verge of writing a manual check for an empty string and setting it to null if the string is empty. This seems pretty kludgy. What's the correct way to send either nothing back or a null value to the server on form submit?
Thanks!