2014-09-02 82 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循环。如果有人感兴趣,我可以发布整个代码!