[fpc-devel] fcl-web webdata example(s) on Windows has some problems
ABorka
fpc-devel at aborka.com
Thu Aug 19 00:42:57 CEST 2010
..snip...
> We can add the "rows" for convenience, but nevertheless the error handler
> must also handle the 'response' case.
>
> Michael.
Hi Michael,
I've created an updated ExtJS error handler for the demo programs that
handle all these response messages from FCL-web without the need to
change the internals and play with the "rows". We just need to update
the *.js files for the demos.
=================================CODE START
// Listen to errors.
data.addListener('exception', function(proxy, type, action, options,
res) {
if (type === 'remote') {
Ext.Msg.show({
title: 'REMOTE EXCEPTION',
msg: res.message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}else{//type === 'response'
if (res.responseText !== undefined){//there is a responseText so
we can process
var succ = undefined;
var mess = "";
try {
//////mark start
var response = Ext.util.JSON.decode(res.responseText);
succ = response.success;
mess = response.message;
//////mark end
if ((succ !== undefined)&&(!succ)){//success == false
Ext.Msg.show({
title: 'REMOTE EXCEPTION/ERROR',
msg: mess,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
};
}//try
catch (err) {
Ext.MessageBox.alert('ERROR', 'Could not decode server
response: ' + res.responseText);
};//catch
};
};//else
});//addListener
==================================CODE END
For XML communication we need to change between the "mark start / mark
end" to
//////mark start
var response = document.createElement('div');
response.innerHTML = res.responseText;
s = Ext.DomQuery.selectValue('success', response);
switch (s.toLowerCase()) {
case "true" : succ = true;
case "false": succ = false;
};//switch
mess = Ext.DomQuery.selectValue('message', response);
//////mark end
AB
More information about the fpc-devel
mailing list