bmacdon1
16 Aug 2011, 12:54 PM
Hello,
I have been struggling attempting to get the errorReader(or even xml data) to work properly on a form submit without using a model. The code snippet below comes from the api section Ext.form.action.Submit (http://docs.sencha.com/ext-js/4-0/#/api/Ext.form.action.Submit) and implies to me it is not necessary to build a model for a simple reader.
errorReader: new Ext.data.reader.Xml({
record : 'field',
success: '@success'
}, [ 'id', 'msg' ])
I ended up using the Extjs XML sample (http://dev.sencha.com/deploy/ext-4.0.2a/examples/form/xml-form.html) to get the submit somewhat working. This sample required the use of a model. On a side note, this functionality doesn't work for me on the sample page. The submit is always disabled.
If I don't include a model I get an error "this.model is undefined." The closest post I've found dealing with a similar issue is here:
(http://www.sencha.com/forum/showthread.php?133382-Problems-using-action.Load-with-XML-Reader-%28migrating-from-3.x-to-4.x%29)Problems using action.Load with XML Reader (migrating from 3.x to 4.x) (http://www.sencha.com/forum/showthread.php?133382-Problems-using-action.Load-with-XML-Reader-%28migrating-from-3.x-to-4.x%29)
No one answered his question, but it seems similar to what I am dealing with. This is a snippet of my code. It is possible I am doing something wrong all together and it would be great if someone could point me in the right direction. And yes, I know its over kill to be doing this for a log in page, but I am attempting to rely on ExtJS framework to build everything.
var loginForm = Ext.create('Ext.form.Panel',
{
title: 'Login Form',
bodyPadding: 5,
width: '462',
height: '333',
autoScroll:true,
url: '../login',
clientValidation:false,
errorReader: Ext.create('Ext.data.reader.Xml', {
record : 'MESSAGE',
success: '@success'
},['MESSAGE_TYPE'])
});
var loginFormButtonsubmit= Ext.create('Ext.Button',{
text: 'Submit',
formBind: true,
handler: function()
{
var form = this.up('form').getForm();
if (form.isValid())
{
form.submit({
success: function(form, action){
alert('Success')
},
failure: function(form, action){
alert('Failed')
}
});
}
else
{
Ext.Msg.alert('', 'This page contains errors. Correct the errors indicated below each field, and then retry this action.')
}
}
});
loginForm.add(loginFormButtonsubmit);
I have been struggling attempting to get the errorReader(or even xml data) to work properly on a form submit without using a model. The code snippet below comes from the api section Ext.form.action.Submit (http://docs.sencha.com/ext-js/4-0/#/api/Ext.form.action.Submit) and implies to me it is not necessary to build a model for a simple reader.
errorReader: new Ext.data.reader.Xml({
record : 'field',
success: '@success'
}, [ 'id', 'msg' ])
I ended up using the Extjs XML sample (http://dev.sencha.com/deploy/ext-4.0.2a/examples/form/xml-form.html) to get the submit somewhat working. This sample required the use of a model. On a side note, this functionality doesn't work for me on the sample page. The submit is always disabled.
If I don't include a model I get an error "this.model is undefined." The closest post I've found dealing with a similar issue is here:
(http://www.sencha.com/forum/showthread.php?133382-Problems-using-action.Load-with-XML-Reader-%28migrating-from-3.x-to-4.x%29)Problems using action.Load with XML Reader (migrating from 3.x to 4.x) (http://www.sencha.com/forum/showthread.php?133382-Problems-using-action.Load-with-XML-Reader-%28migrating-from-3.x-to-4.x%29)
No one answered his question, but it seems similar to what I am dealing with. This is a snippet of my code. It is possible I am doing something wrong all together and it would be great if someone could point me in the right direction. And yes, I know its over kill to be doing this for a log in page, but I am attempting to rely on ExtJS framework to build everything.
var loginForm = Ext.create('Ext.form.Panel',
{
title: 'Login Form',
bodyPadding: 5,
width: '462',
height: '333',
autoScroll:true,
url: '../login',
clientValidation:false,
errorReader: Ext.create('Ext.data.reader.Xml', {
record : 'MESSAGE',
success: '@success'
},['MESSAGE_TYPE'])
});
var loginFormButtonsubmit= Ext.create('Ext.Button',{
text: 'Submit',
formBind: true,
handler: function()
{
var form = this.up('form').getForm();
if (form.isValid())
{
form.submit({
success: function(form, action){
alert('Success')
},
failure: function(form, action){
alert('Failed')
}
});
}
else
{
Ext.Msg.alert('', 'This page contains errors. Correct the errors indicated below each field, and then retry this action.')
}
}
});
loginForm.add(loginFormButtonsubmit);