Server exceptions trapping

Coordinator
Apr 14, 2008 at 9:44 AM
Hello all,

as you can see, latest release (v1.05) implements a great new feature: Server exceptions trapping.
Every exceptions trhown on server side can be catched and interpreted in different ways on client side.

Thanks for your support and downloads,
magicben
Apr 26, 2008 at 4:21 AM
This would be a cool feature.Thanks for your efforts.

Now ,I doubt that DynAjax can support "overload method" or not?

if can't,I have a idea to make DynAjax support "overload ".
Coordinator
Apr 27, 2008 at 9:41 AM
Edited Apr 27, 2008 at 9:42 AM
Hello Kaima,

thank you for your post.
no, DynAjax doesn't support overload, and I'm interested in your idea to make it support overload...
It's a pleasure to see people who are interested in DynAjax improvements, don't hesitate to give us more and more feedbacks.

magicben
Apr 28, 2008 at 6:29 AM
Actually,just make javascript support overload ,then DynAjax can support overload too.By the way,I have made DynAjax support jQuery.
-----------------------------------------------
dynAjax.aspx (for jQuery)
-----------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Ajax.aspx.cs" Inherits="WWW.Scripts.Ajax" %>
function DynAjaxManager(){}
DynAjaxManager.prototype = {
initialize: function() {},
getDynaData: function(callBackMethod,classId,methodName,args) {
var dynaResult = null;
var asyncCall = false;
if (callBackMethod && typeof callBackMethod == "function") {
asyncCall = true;
}
$.ajax({
type:"POST",
url:"_AjaxHandler.aspx",
data:"classId=" + encodeURIComponent(classId) + "&methodName=" + encodeURIComponent(methodName) + "&methodArgs=" + encodeURIComponent(JSON.stringify(args)),
async:asyncCall,
success:function(request){
dynaResult = eval('('request')');//JSON.parse(request);
if (callBackMethod) {
callBackMethod(dynaResult);
}
},
error:function(e) {
dynaResult = null;
if (callBackMethod) {
callBackMethod(dynaResult);
}
}
});
return dynaResult;
}
};
var dynAjaxManager = new DynAjaxManager();

//this method can make javascript support overload
function DynAjaxAddMethod(object, name, fn){
var old = object name ;
object name = function(){
if ( fn.length == arguments.length ){
return fn.apply( this, arguments );
}
else if ( typeof old == 'function' ){
return old.apply( this, arguments );
}
}
};

<%= dynamicJsText %>



-----------------------------------------------
dynAjax.aspx.cs
-----------------------------------------------
... ....
/// <summary>
/// create【class】
/// </summary>
/// <param name="classNode"></param>
protected void addClassDefinition(XmlNode classNode)
{
string className = classNode.Attributes"id".Value;
dynamicJsText += "function " + className + "DYNClass(){";

XmlNodeList nodesList = classNode.SelectNodes("dynajax:method", nsmgr);
for (int i = 0; i < nodesList.Count; i++)
{
addMethodDefinitionReload(className, nodesListi);
}
dynamicJsText += "\n};\n";
dynamicJsText += "var " + className + " = new " + className + "DYNClass();\n\n";
}
/// <summary>
/// create【overload javascript methoed】
/// </summary>
/// <param name="className"></param>
/// <param name="methodNode"></param>
protected void addMethodDefinitionReload(string className, XmlNode methodNode)
{
XmlNodeList paramsList = methodNode.SelectNodes("dynajax:param", nsmgr);
string paramsListStr = "";
string separator = "";
foreach (XmlNode paramNode in paramsList)
{
paramsListStr += separator + paramNode.Attributes"name".Value;
separator = ",";
}

string methodName = methodNode.Attributes"name".Value;
if(paramsList.Count!=0){
dynamicJsText += "\n DynAjaxAddMethod(this,\"" + methodName + "\",function(callBackMethod," + paramsListStr + ") {\n";
}else{
dynamicJsText += "\n DynAjaxAddMethod(this,\"" + methodName + "\",function(callBackMethod) {\n";
}
dynamicJsText += " var args = " + paramsListStr + ";\n";
dynamicJsText += " return dynAjaxManager.getDynaData(callBackMethod,'" + className + "','" + methodName + "',args);\n";
dynamicJsText += " });";
}
... ...
Apr 28, 2008 at 6:36 AM
Edited Apr 28, 2008 at 6:37 AM
after that ,you should change your call action in javascript like this:
synchronous
var response = MyClass.myMethod(null,myArgs);
if (response >= 2) {
--- code here ---
}


asynchronous
MyClass.myMethod(function(response) {
if (response >= 2) {
--- code here ---
}
},myArgs);