2016-11-02 10 views
0

私のXpageアプリケーションに剣道UIグリッドがあります。グリッドは、JavaクラスにフックされたマネージドBeanにバックアップされたカスタムレストサービスへの呼び出しによって設定されます。Xpages:休憩サービスで電話をかけるときにparmを取得できません

読んだ作品は素晴らしいですが、削除がうまくいくのに問題があります。それは働いていて、何か変わった(何が分からないのか)、今はそれほど変わっていない。エラーが剣道UI部分か休憩サービス部分にあるかどうかはわかりませんので、ここで両方とも投稿します。

私はJavaをデバッグすることができますが、私はdoDeleteメソッドになっていますが、ドキュメントを取得して削除するために必要なparm(UNID)を取得できません。次のように

Javaの一部です:

package com.scoular.rest; 

import java.io.IOException; 
import java.io.Writer; 
import java.util.Vector; 

import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 

import org.openntf.domino.Database; 
import org.openntf.domino.Document; 
import org.openntf.domino.Session; 
import org.openntf.domino.View; 
import org.openntf.domino.ViewEntry; 
import org.openntf.domino.ViewNavigator; 
import org.openntf.domino.utils.Factory; 

import com.ibm.commons.util.io.json.JsonException; 
import com.ibm.commons.util.io.json.util.JsonWriter; 
import com.ibm.domino.services.ServiceException; 
import com.ibm.domino.services.rest.RestServiceEngine; 
import com.ibm.xsp.extlib.component.rest.CustomService; 
import com.ibm.xsp.extlib.component.rest.CustomServiceBean; 
import com.scoular.cache.CacheBean; 

public class restPC extends CustomServiceBean { 

    @SuppressWarnings("unused") 
    private Database appData; 

    @Override 
    public void renderService(CustomService service, RestServiceEngine engine) throws ServiceException { 

     try { 

      HttpServletRequest request = engine.getHttpRequest(); 
      HttpServletResponse response = engine.getHttpResponse(); 

      response.setHeader("Content-Type", "application/json; charset=UTF-8"); 
      String method = request.getMethod(); 

      if (method.equals("GET")) { 
       this.doGet(request, response); 
      } else if (method.equals("DELETE")) { 
       this.doDelete(request, response); 
      } 

     } catch (Exception e) { 
      throw new RuntimeException(e); 
     } 
    } 

    private void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { 

     // Map prmMap = request.getParameterMap(); 
     // String id = prmMap.get("id").toString(); 
     String prmUNID = request.getParameter("id"); 
     Database DB = this.getAppData(); 
     // String t = request.getParameter("unid"); 
     Document tmpDoc = DB.getDocumentByUNID(prmUNID); 

     if (tmpDoc != null) { 
      tmpDoc.remove(true); 
     } else { 
     } 

    } 

私は、Javaコードの関連部分を掲載しました。

デルタが呼び出されるXpageのスクリプト部分(剣道グリッド)です。

<!--The Grid--> 
<div class="row" id="grid" style="margin-top:15px"></div> 
<!--The Grid--> 
</div> 
<!--The Container--> 


    <xp:scriptBlock id="scriptBlock1"> 
     <xp:this.value><![CDATA[ $(document).ready(function() { 


     // Setup Rest Service 
     var loc = (location.href); 
     var url = loc.substring(0, loc.lastIndexOf("/")) + "/xpRest.xsp/custom/"; 
     var searchInput = XSP.getElementById("#searchInput"); 
     var crudServiceBaseUrl = "xpRest1.xsp", 
     dataSource = new kendo.data.DataSource({ 
      autoSync : true, 
      transport : { 
       read   : { 
        url   : url + "get?status=All", 
        dataType : "json", 
        type  : "GET" 
       }, 
       destroy   : { 
       url: function (e) { 
            return "delete?" + e.id; 
            }, 
        //url  : url + "delete?id=",  I HAVE ALSO TRIED THIS 
        dataType : "json", 
        type  :"DELETE" 
        } 
      }, 
      batch: true, 
      pageSize : 15, 
      scrollable : false, 
      height : 600, 
      parameterMap: function(options, operation) { 
        if (operation !== "read" && options.models) { 
         return {models: kendo.stringify(options.models[0].id)}; 
        }}, 
       schema : { 
       model : { 
        id : "unid", 
        fields : { 
         serialNumber : { 
          type : "string", 
          editable : false 
         }, 
         statusDescription : { 
          type : "string", 
          editable : false 
         }, 
         lastActionDate : { 
          type : "date", 
          editable : false 
         }, 
         lastActionUser : { 
          type : "string", 
          editable : false 
         }, 
         lastActionLocation : { 
          type : "string", 
          editable : false 
         }, 
         assetTag : { 
          type : "string", 
          editable : false 
         }, 
         model : { 
          type : "string", 
          editable : false 
         }, 
         unid : { 
          type : "string", 
          nullable : false 
         } 
        } 
       } 
      } 
     }); 

     // Grid 
     grid = $("#grid").kendoGrid({ 
      excel:{ 
       fileName: "PC Inventory All.xlsx", 
       filterable:true, 
       allPages:false 
       }, 
      dataSource : dataSource, 
      dataBound: onDataBound, 
      columns : [ 
        //define template column with checkbox and attach click event handler 
        {width: "30px", 
        template: "<input type='checkbox' class='checkbox' />" },   
        { 
         width : "150px", 
         field : "serialNumber", 
         title : "Serial Number", 
         template : "<a href=xpFormPC.xsp?action=openDocument?&key=#=unid#><h5><b>#=serialNumber#</b></h5></a>" 
        }, { 
         width : "150px", 
         field : "statusDescription", 
         title : "Status", 
         template :"#=status#&nbsp#=statusDescription#" 
        }, { 
         width : "150px", 
         field : "lastActionDate", 
         title : "Last Action Date", 
         template: "#= (lastActionDate == null) ? ' ' : kendo.toString(kendo.parseDate(lastActionDate, 'yyyy-mm-dd'), 'MM/dd/yyyy') #" 
        }, { 
         width : "150px",  
         field : "lastActionUser", 
         title : "Last Action User" 
        }, { 
         width : "200px", 
         field : "lastActionLocation", 
         title : "Last Action Location" 
        }, { 
         width : "150px",   
         field : "assetTag", 
         title : "Asset Tag" 
        }, { 
         //width : "150px",   
         field : "model", 
         title : "Model" 
        }, { 
         hidden: false, 
         width : "50px", 
         template : "<button type='button' class='btn btn-danger k-grid-delete'>X</button>" 
        } 
      ], 
      editable : {mode:"inline"}, 
      pageable : { 
       refresh : true, 
       pageSizes : true, 
       buttonCount : 5 
      }, 
      groupable : true, 
      reorderable : true, 
      filterable : true, 
      selectable : true, 
      sortable : true, 
      resizable : true, 
      columnMenu : true 
      }); 


]]></xp:this.value> 
    </xp:scriptBlock> 
+0

あなたは郵便配達を使用する場合がありますhttps://www.getpostman.com/ – stwissel

答えて

0

OPのソリューション。

私が間違っていたことを理解しました。私はパラメータマップを送信していたので、パラメータマップを取得する必要がありました。

だから、Javaエージェントでの私のコードは次のように変更:

private void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException, NotesException { 

    Map<String, String[]> prmMap = request.getParameterMap(); 
    String[] prmID = prmMap.get("unid"); 
    Database DB = this.getAppData(); 
    Document tmpDoc = DB.getDocumentByUNID(prmID[0]); 

    if (tmpDoc != null) { 
     tmpDoc.remove(true); 
    } 
} 
関連する問題