PDA

View Full Version : Ext.form - waitMsg appears forever?



Saeven
11 May 2007, 1:17 PM
I'm guessing that the server end isn't returning the expected response. Here's the form that I am using



var simple = new Ext.form.Form({
labelWidth: 75, // label settings here cascade unless overridden
url: xmlrpcURL,
buttonAlign: 'center',
baseParams: {
command: 'registerUser'
}
});

// REGISTRATION FORM FIELDS
simple.add(
new Ext.form.TextField({
fieldLabel: 'First Name',
name: 'first',
width: 300,
allowBlank:false
}),

new Ext.form.TextField({
fieldLabel: 'Last Name',
name: 'last',
width: 300,
allowBlank:false
}),

new Ext.form.TextField({
fieldLabel: 'Company',
name: 'company',
width: 300
}),

new Ext.form.TextField({
fieldLabel: 'Email',
name: 'email',
vtype:'email',
width: 300,
allowBlank:false
})
);

simple.addButton( 'Save', function(){ simple.submit( {waitMsg: 'Thank you, one moment please...', reset: false }); } );
simple.addButton( 'Cancel', function(){ updateNavTable(); } );
simple.on({
actioncomplete: function( form, action ) {
alert( action.type );
alert( action.result );
}
});
simple.render( 'navtable' );


It posts to the page properly, and firebug shows that it returns a response such as:



<response>
<result>1</result>
</response>


...however, the waitMsg specified, shows indefinitely after a submission takes place.

Help appreciated.
Alex

tryanDLS
11 May 2007, 1:29 PM
There are a number of other threads about this as well as an example. You response needs to include success true/false attribute

Saeven
14 May 2007, 11:05 AM
Thanks for the response Tim,

I had read the examples, and searching the forums is a bit of a hit and miss affair. I had ended up with this code:



var simple = new Ext.form.Form({
labelWidth: 75, // label settings here cascade unless overridden
url: xmlrpcURL,
buttonAlign: 'center',
baseParams: {
action: 'registerUser'
},
// configure how to read the XML Data
reader : new Ext.data.XmlReader({ success: 'success' }, [ 'message', 'success' ] )
});



And this XML return:


<?xml version="1.0" encoding="utf-8" ?>
<Auracle>
<Command>RegisterUser</Command>
<Result>User successfully registered</Result>
<TR>1</TR>
<success>true</success>
</Auracle>


And the waitMsg still remains.

tryanDLS
14 May 2007, 11:10 AM
Compare your reader to the code in the xml forms example which reads an xml response for validation.

Saeven
14 May 2007, 11:14 AM
Hi Tim,

I don't understand the nature of your response - I've just paid for a premium support membership if that helps squeeze out some pinpoint answers. I see that there is a difference where the @ symbol is concerned, but I'm reading an element, not an attribute..

Is it absolutely necessary that a record be read otherwise? Here's the code from the example, which differs not so greatly from what I've gathered..



reader : new Ext.data.XmlReader({
record : 'contact',
success: '@success'
}, [
{name: 'first', mapping:'name/first'}, // custom mapping
{name: 'last', mapping:'name/last'},
'company', 'email', 'state',
{name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
]),


Compare I have...

Cheers.
Alex

tryanDLS
14 May 2007, 11:38 AM
Isn't that the response you're trying to get after form submit? I don't see an errorReader in your code - the reader is used to read the xml to load your form; errorReader handles the messages back from submit. You can also try setting BPs in Action.Submit success and handleReponse. This will allow you to see what's happening with the response object coming back.

Saeven
14 May 2007, 11:43 AM
I see, I misunderstood in this case! An error reader, isn't necessarily there to read errors. It's actually a "submissionResponseReader".. let me go ahead with this.

Saeven
14 May 2007, 12:46 PM
Does the success indicator necessarily have to be an attribute to the XML response's root element?

Saeven
14 May 2007, 1:14 PM
I've switched to a JSON format, and it works off the bat. Not certain if the XML format is picky or buggy...

I can't find any examples or documentation as to what the per-field validation response in XML should look like. For example how would I return that my field with name 'email' in the form shown in the first post, was bad? (...aside from returning a success, of false of course..)

Thanks.
Alex