PDA

View Full Version : [FIXED][3.0.0] action.failureType is not defined



migolo
2 Aug 2009, 9:50 PM
Hi everybody

I created a Login Form using Ext.Direct as the method of login.
When submit action is called I defined two parameters: success and failure functions.

They are like this:


Ext.getCmp("formlogin").getForm().submit({
success: function(form, action) {
document.location.reload(true);
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
The problem I get is when I return false in the response ( {"type":"rpc","tid":"2","action":"UserManagment","method":"login","result":{"success":false,"msg":"No haz iniciado"}} ) I don't get an alert also with firebug I don't get the "failureType" variable so I think I forgot to include something or I am doing something wrong.

Can you help me?

My firebug output is attached.

Best regards.

Miguel González

Condor
2 Aug 2009, 9:59 PM
Looking at the code it seems that it will only return SERVER_INVALID if you also include 'errors' with success:false.

I propose to change:

Ext.override(Ext.form.Action.Submit, {
success : function(response){
var result = this.processResponse(response);
if(result === true || result.success){
this.form.afterAction(this, true);
return;
}
if(result.errors){
this.form.markInvalid(result.errors);
//this.failureType = Ext.form.Action.SERVER_INVALID;
}
this.failureType = Ext.form.Action.SERVER_INVALID;
this.form.afterAction(this, false);
}
});

(moving this to the Bugs section)

mjlecomte
3 Aug 2009, 9:04 PM
Marking as OPEN

evant
4 Aug 2009, 5:46 AM
Fixed in SVN.

Condor
25 Sep 2009, 4:35 AM
The form success handler and the request success handler are two completely different methods.

The request success handler (= the method mentioned above) calls this.form.afterAction(this, true), which will execute the form success handler.

arrakis
25 Sep 2009, 4:39 AM
Thanks Condor, I just realised this myself while taking a closer look of the code, that's why I decided to delete my post, before I notice your reply (and honestly, I didn't expect to get such a quick answer).