美好的一天夥計!JSON-RPC和當前文檔的句柄
我有一個調用(CSJS)到我的XPage中的JSON-RPC服務來獲取viewScope變量的值。我使用這個調用來遍歷我的字段名稱(動態)並驗證它們。
我無法弄清楚如何從RPC服務中獲取這些字段綁定到的數據源(在我的情況下爲document1)的句柄。
這裏的電話:
// Use the JSON-RPC Service to get the number of asset item rows
// from the viewScope variable
var deferred = myRPCService.getScopeVar();
deferred.addCallback(function(result){
alert(result); // <-- viewScope variable value
// get the dynamic field names for the asset items based on row #
var itemname = '';
for (var i = 1; i < result; i++) {
var itemname = 'replace'+(i < 10? '0':'')+ i
if (document1.getItemValueString(itemname) == ""){
// do this
} else{
// do that
}
}
});
我確實從RPC調用的viewScope變量的值,但我不能讓不止於此。任何指針/例子將不勝感激。
感謝,
丹
PS:請參閱下面我的意見......
附錄:我想我可以通過將JSON-RPC調用的響應(結果)分配給一個CSJS變量來避開這個問題,然後我可以繼續在回調函數之外進行處理。但是,時間安排並不重要。 //使用JSON-RPC服務獲取viewScope變量值 var deferred = myRPCService.getScopeVar(); var rowCount =「」; deferred.addCallback(function(result){ rowCount = result; alert(「CT1 =」+ rowCount); }); alert(「CT2 =」+ rowCount); 第二次警報CT2在第一次警報之前用一個空值觸發,然後CT1觸發警報。嘆! –