07-18-2011 08:23 AM
Alfresco.DocumentList.prototype.onActionSubscribe = function DL_onActionSubscribe(file)
{
var failureMessage;
var failureHandler = function crest_failureHandler(oResponse)
{
//destroyLoaderMessage();
// Clear out deferred functions
//this.afterDocListUpdate = [];
var json ={};
if (oResponse.json)
{
json = oResponse.json;
//console.log("code "+json.status.code);
//console.log("json message "+json.message);
var status = json.status.code;
if (status == 500)
{
console.log("status "+status+file.displayName);
failureMessage = this.msg("message.subscribe.already", file.displayName);
}
else
{
console.log("status "+status);
failureMessage = this.msg("message.subscribe.failure", file.displayName);
}
console.log("failureMessage "+failureMessage);
}
};
this.modules.actions.genericAction(
{
success:
{
message: this.msg("message.subscribe.success", file.displayName)
},
failure:
{
callback:
{
fn: failureHandler,
scope: this
},
message: failureMessage
},
webscript:
{
name: "subscribe/site/{site}/{container}",
method: Alfresco.util.Ajax.GET
},
params:
{
site: this.options.siteId,
container: this.options.containerId
},
config:
{
requestContentType: Alfresco.util.Ajax.JSON,
dataObj:
{
nodeRefs: [file.nodeRef]
}
}
});
};
})();Now based on the status code I want to display different error messages.07-18-2011 09:40 AM
Any idea how can I pass the failureMessage from the callback function back to calling function?You can't directly, because the network call is asynchronous. Either create a new function that the failure handler calls with the reponse, or handle the message display in the failure handler itself.
07-18-2011 10:37 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.