2014-09-02 129 views
0

我有一個slickgrid屏幕(在常規的Domino表單上),其中用戶可以選擇和更新一些文檔。我需要顯示每個選定文檔的彈出式顯示狀態,所以我創建了一個XPage。在我的XPage中,我循環選定的文檔數組(json)併爲每個文檔調用一個RPC方法。調用RPC方法的代碼位於XPAGE的onClientLoad事件點擊的按鈕中。 RPC工作正常,因爲文檔正在根據需要進行更新。早些時候,我已經將RPC返回的HTML代碼添加到了HTML表中。它適用於Firefox,但不適用於IE。現在我試圖使用Dojo追加行,但這也不起作用。xpages JSON-RPC來自回調函數的服務處理響應


這是我按鈕點擊的Javascript代碼。


var reassign = window.opener.document.getElementById("ResUsera").innerHTML; 
var arr = new Array(); 
var grid = window.opener.gGrid; 
var selRows = grid.getSelectedRows(); 
for (k=0;k<selRows.length;k++) 
{ 
    arr.push(grid.getDataItem(selRows[k])); 
} 
var tab = dojo.byId("view:_id1:resTable"); 
while (arr.length > 0) 
{ 
    var fldList = new Array(); 
    var ukey; 
    var db; 
    var reqStatusArr = new Array(); 
    var docType; 
    var docno; 

    ukey = arr[0].ukey; 
    db = arr[0].docdb; 
    docType = arr[0].doctypeonly; 
    docno = arr[0].docnum; 
    fldList.push(arr[0].fldIndex); 
    reqStatusArr.push(arr[0].reqstatusonly); 

    arr.splice(0,1) 
    for (i=0;i < arr.length && arr.length>0;i++) 
    { 
     if ((ukey == arr[i].ukey) && (db == arr[i].docdb)) 
     { 
      fldList.push(arr[i].fldIndex); 
      reqStatusArr.push(arr[i].reqstatusonly); 
      arr.splice(i,1); 
      i--; 
     } 
    } 
    console.log(ukey+" - "+db+" - "+docno+" - "+docType); 
    var rmcall = faUpdate.updateAssignments(db,ukey,fldList,reassign); 
    rmcall.addCallback(function(response) 
    { 
     require(["dojo/html","dojo/dom","dojo/domReady!"],function(html,dom) 
     { 
       var tbdy = dom.byId("view:_id1:resTable").getElementsByTagName("tbody"); 
       html.set(tbdy, 
       tbdy.innerHTML+"<tr>"+ 
       "<td>"+docType+"</td>"+ 
       "<td>"+docno+"</td>"+ 
       "<td>"+reqStatusArr.join("</br>")+"</td>"+ 
       "<td>"+response+"</td></tr>" 
       ); 

     }); 
    }); 
} 
dojo.byId("view:_id1:resTable").style.display="inline"; 
dojo.byId("idLoad").style.display="none"; 

RPC服務代碼


<xe:jsonRpcService 
       id="jsonRpcService2" 
       serviceName="faUpdate"> 
       <xe:this.methods> 
        <xe:remoteMethod name="updateAssignments"> 
         <xe:this.arguments> 
          <xe:remoteMethodArg 
           name="dbPth" 
           type="string"> 
          </xe:remoteMethodArg> 
          <xe:remoteMethodArg 
           name="uniquekey" 
           type="string"> 
          </xe:remoteMethodArg> 
          <xe:remoteMethodArg 
           name="fieldList" 
           type="list"> 
          </xe:remoteMethodArg> 
          <xe:remoteMethodArg 
           name="reassignee" 
           type="string"> 
          </xe:remoteMethodArg> 
         </xe:this.arguments> 
         <xe:this.script><![CDATA[print ("starting update assignments from future assignments page"); 
    var db:NotesDatabase = null; 
    var vw:NotesView = null; 
    var doc:NotesDocument = null; 

    try{ 
     db=session.getDatabase("",dbPth); 
     if (null!= db){ 
      print(db.getFileName()); 
      vw = db.getView("DocUniqueKey"); 
      if (null!=vw){ 
       print ("got the view"); 
       doc = vw.getDocumentByKey(uniquekey); 
       if (null!=doc) 
       { 
        //check if the document is not locked 
        if (doc.getItemValueString("DocLockUser")=="") 
        { 
         print ("Got the document"); 

         for (i=0;i<fieldList.length;i++) 
         { 
          print (fieldList[i]); 
          doc.replaceItemValue(fieldList[i],reassignee); 
         } 
         doc.save(true); 
         return "SUCCESS"; 
        } 
        else 
        { 
         return "FAIL - document locked by "+session.createName(doc.getItemValueString("DocLockUser")).getCommon(); 
        } 
       } 
       else 
       { 
        return "FAIL - Contact IT Deptt - Code: 0"; 
       } 
      } 
      else 
      { 
       return "FAIL - Contact IT Deptt - Code: 1"; 
      } 
     } 
     else 
     { 
      return "FAIL - Contact IT Deptt - Code: 2"; 
     } 

    } 
    catch(e){ 
     print ("Exception occured --> "+ e.toString()); 
     return "FAIL - Contact IT Deptt - Code: 3"; 
    } 
    finally{ 
     if (null!=doc){ 
      doc.recycle(); 
      vw.recycle(); 
      db.recycle(); 
     } 
    }]]></xe:this.script> 
        </xe:remoteMethod> 
       </xe:this.methods> 
    </xe:jsonRpcService> 

在此先感謝

回答

0

我已解決此問題。首先,CSJS變量在回調函數中不可靠地設置,所以我讓RPC返回了我想要的HTML字符串。其次是我在CSJS中的錯誤。我試圖用

var tbdy = dom.byId("view:_id1:resTable").getElementsByTagName("tbody"); 

地方,因爲它返回一個數組所以它應該是

var tbdy = dom.byId("view:_id1:resTable").getElementsByTagName**("tbody")[0]**; 

來從表TBODY也讓我感動的tbody上面while循環。如果有人感興趣,我可以發佈整個代碼!