PDA

View Full Version : client failure msg



bhomass
24 Oct 2007, 7:04 PM
where should the client validation error handling go, to be distinct from the server response failure?

I have this code
myform.submit({
clientValidation: true,
failure: function(form_instance_update, action) {
Ext.MessageBox.alert('Error Message', action.result.errorInfo);
},
success: function(form_instance_update, action) {
Ext.MessageBox.alert('Confirm', action.result.info);
}
});
});

when the client validation fails, and I do a submit, I get a
action.result has no property. that's because the errorInfo is suppose to come from the server response. shouldn't there be a separate handler which is dedicated to the client validation failure?

I guess, I'll just add a if-else inside failure: module.

devnull
25 Oct 2007, 10:00 AM
I guess I don't understand why you are even doing a submit if client validation has failed...

bhomass
25 Oct 2007, 10:05 AM
ever heard of fool proof design?

you can't beat up on the user/customer for ignoring the red. the system has to handle a mistaken click regardless.

devnull
25 Oct 2007, 10:15 AM
Thats what I mean. Are you saying you are calling this code directly from your submit button? You can't asume the Ext knows how you want to validate the form, that is up to you.
At the very least, I check myform.isValid() (prevent the customer from "ignoring the red"). I generally also check myform.isDirty() to help prevent early submissions. If either of these fail, I bail out of the function before myform.submit() is called.

*edit*
perhaps something has changed with Ext 2.0 regarding forms, I will research what the 'clientValidation' option does...

devnull
25 Oct 2007, 10:22 AM
I see the documentation is either not complete or not very clear on how this is supposed to work now, would you mind posting what it was that you found that fixed the issue?

Animal
25 Oct 2007, 11:28 AM
It fires 'actionfailed'.

action.failureType will be Ext.form.Action.CLIENT_INVALID

Animal
25 Oct 2007, 11:30 AM
The docs have been really updated well, but Jack doesn't seem to run the generator over the source very regularly!

devnull
25 Oct 2007, 11:44 AM
ahh, that makes sense.
I do like this approach, seems easy to use.

bhomass
26 Oct 2007, 2:07 PM
what I found was even when I don't set clientValidation: true, the code still fails, and I end up in failure: clause.

it would be nice if form.isDiry() is also checked automatically.

tryanDLS
26 Oct 2007, 2:11 PM
what I found was even when I don't set clientValidation: true, the code still fails, and I end up in failure: clause.
You'll have to set some breakpoints and see what's causing failure.


it would be nice if form.isDiry() is also checked automatically.You mean only submit if isDirty=true? That's not a good idea - by default, a form submit doesn't care whether the form is dirty or not. As Animal said, that's a special case that you should handle.