有人可以说明为什么这个CSJS代码总是运行我的SSJS代码而不管CSJS似乎返回真或假?
CSJS代码
message = "Starting Settle ATM Process..."
$(".infoMessage").text(message);
atmID = $("input.atmID").val(); //pull from hidden input
var deferred = atmRPC.closeATMFirstSettle();
deferred.addCallback(function(result){
if (result == "false") {
alert("Close command failed during 1st Settle ATM process. System will retry...");
var insideDeferred = atmMRPC.closeATMSecondSettle();
insideDeferred.addCallback(function(result) {
if (result == "false") {
message = "Close command failed during Settle ATM process. Please try again later."
$(".infoMessage").text(message);
atmRPC.updateInfoMsg(message);
return false;
} else if(result == "true"){
var deferred = atmRPC.settleATMFirst();
deferred.addCallback(function(result){
if (result == "false") {
alert("Settlement failed during 1st attempt. System will retry...");
var insideDeferred = atmMRPC.settleATMSecond();
insideDeferred.addCallback(function(result) {
if (result == "false") {
message = "Settlement failed. Please try again later."
$(".infoMessage").text(message);
atmRPC.updateInfoMsg(message);
return false;
} else if(result == "true"){
message = atmID + " has been successfully Settled."
$(".infoMessage").text(message);
atmRPC.updateInfoMsg(message);
// return true;
}
})
} else if(result == "true"){
message = atmID + " has been successfully Settled."
$(".infoMessage").text(message);
atmRPC.updateInfoMsg(message);
// return true;
}
})
}
})
} else if(result == "true"){
var deferred = atmRPC.settleATMFirst();
deferred.addCallback(function(result){
if (result == "false") {
alert("Settlement failed during 1st attempt. System will retry...");
var insideDeferred = atmMRPC.settleATMSecond();
insideDeferred.addCallback(function(result) {
if (result == "false") {
alert("Settlement failed during 1st attempt. System will retry...");
message = "Settlement failed. Please try again later."
$(".infoMessage").text(message);
atmRPC.updateInfoMsg(message);
return false;
} else if(result == "true"){
message = atmID + " has been successfully Settled."
$(".infoMessage").text(message);
atmRPC.updateInfoMsg(message);
// return true;
}
})
} else if(result == "true"){
message = atmID + " has been successfully Settled."
$(".infoMessage").text(message);
atmRPC.updateInfoMsg(message);
// return true;
}
})
}
})
closeATMFirsSettle和closeATMSecondSettle与布尔变量的异常相同
if(atmBean.atmStatus == "OPEN" || atmBean.atmStatus == "WOUNDED") {
var firstTry:boolean = atmBean.closeATM(atmBean.atmID, userBean.userID);
return firstTry.toString();
} else if(atmBean.atmStatus == "CLOSED") {
return "true";
} else {
return "false";
}
settATMFirst和settleATMSecond与布尔变量
的例外相同sessionScope.infoMsg = null;
try {
if(atmBean.atmAmountReceived == null) {
var settleAmt:Integer = Integer.parseInt(atmBean.atmTodaySettlementAmt);
} else {
var settleAmt:Integer = Integer.parseInt(atmBean.atmAmountReceived);
}
} catch(e) {
message:String = "1st Settle ATM Amount Error: " + e;
logInfo(message);
return sessionScope.infoMsg = message;
}
var firstTry:boolean = atmBean.settleATM(atmBean.atmID, userBean.userID, settleAmt);
return firstTry.toString();
atmBean.settleATM
public boolean settleATM(String atmId, String employeeId, Integer settlementAmount, String attempt){
//This method called by RPC control from client JS
AtmOperationSettlementResult result = null;
boolean returnValue = false;
try {
result = AtmTerminalUtil.settleAtm(atmID, employeeId, settlementAmount);
returnValue = result.getSuccess();
if(attempt.equals("Second")) {
System.out.println("ATM Bean - Second Attempt");
if(!returnValue) {
handleATMError(result);
}
}
} catch(Exception e) {
System.out.println(e);
}
//saveATMHistory();
return returnValue; //return status of operation to UI
}
我知道服务器选项卡中的SSJS始终在运行,因为日志条目显示了atmBean.settleATM返回false时设置的viewScope的值。
很抱歉,直到最后一条评论都没有意识到每个人都在想我所谈论的SSJS代码是在RPC中,但我指的是服务器选项卡。