2015-09-09 22 views
0

我是編程和ofbiz的新手。我需要在javascript函數中調用需要來自ftl文件的參數的服務,我想將參數(resiNumber,shipmentId)傳遞給該服務並調用該服務。我有window.location的嘗試,但我得到了:「這些數據應通過使請求主體(表單域)的一部分進行加密,而不是請求URL」如何從ftbiz ofbiz調用服務(帶參數)

這裏是我的FTL代碼:

<script language="JavaScript" type="text/javascript"> 
    var ListShipmentId=[]; 
    function removeShipment(index){ 

     array.splice(index, 1); 
    } 

    function iterateList() 
    { 
     for(index=0;index<ListShipmentId.length;index++) 
     { 
      alert(ListShipmentId[index]); 
     } 
    } 

    function insertResiNumbers() 
    { 
     var resi = document.getElementById('noResi').value; 
     alert(resi); 

     for(index=0;index<ListShipmentId.length;index++) 
     { 
      window.location = "<@ofbizUrl>updateShipmentResiNumber</@ofbizUrl>?shipmentResiNumber=resi&shipmentId=ListShipmentId[index]"; 
      alert('kya'); 
     } 
    } 


</script> 
<div class="screenlet"> 
    <div class="screenlet-title-bar"> 
    <h3>${uiLabelMap.PageTitleEditShiping}</h3> 
    </div> 
    <div class="screenlet-body"> 
     <input type="hidden" name="_useRowSubmit" value="Y"/> 
     <input type="hidden" name="_checkGlobalScope" value="Y"/> 
     <table cellspacing="0" class="basic-table"> 
     <tr class="header-row"> 
      <td><b>${uiLabelMap.shipmentId}</b></td> 
      <td><b>${uiLabelMap.shipmentTypeId}</b></td> 
      <td><b>${uiLabelMap.statusId}</b></td> 
      <td><b>${uiLabelMap.shipmentNumber}</b></td> 
      <td><b>${uiLabelMap.CreatedDate}</b></td> 
      <td><b>${uiLabelMap.lastModifiedDate}</b></td> 
      <td><b>${uiLabelMap.partyIdTo}</b></td> 
      <td><b>${uiLabelMap.CommonAll}<input type="checkbox" name="selectAll" value="${uiLabelMap.CommonY}" onclick="javascript:toggleAll(this, 'selectAllForm');highlightAllRows(this, 'shipmentId_tableRow_', 'selectAllForm');"/></b></td> 
     </tr> 
     <#list shipment as shipment> 
      <tr> 
      <td>${shipment.shipmentId}</td> 
      <td>${shipment.shipmentTypeId}</td> 
      <td>${shipment.statusId}</td> 
      <td>${shipment.shipmentNumber?default("")}</td> 
      <td>${shipment.CreatedDate?default("")}</td> 
      <td>${shipment.lastModifiedDate?default("")}</td> 
      <td>${shipment.partyIdTo?default("")}</td> 
      <td><input type="checkbox" name="_rowSubmit_o_${shipment_index}" value="Y" onclick="javascript:if(this.value=='Y'){ListShipmentId.push('${shipment.shipmentId}');iterateList(); this.value='N';}else{this.value='Y';iterateList();} " /></td> 
      </tr> 
     </#list> 
     </table> 
     <tr> 
     <input type="hidden" name="_rowCount"></input> 
     <td><input type="text" size='20' id='noResi' name='noResi'/></td> 
     <td><input type="submit" value="update" onclick="javascript:alert('ii');insertResiNumbers();"/></td> 
     </tr> 

</div> 

這裏是我的controller.xml代碼服務:

<!-- Kevin --> 
     <request-map uri="updateShipmentResiNumber"> 
     <security https="false" auth="true"/> 
     <event type="service" path="" invoke="updateShipmentResiNumber"/> 
     <response name="success" type="view" value="ShipedbyCustomer"/> 
     <response name="error" type="view" value="ShipedbyCustomer"/> 
    </request-map> 
<!-- Kevin --> 

的services.xml:

<service name="updateShipmentResiNumber" engine="simple" 
     location="component://product/script/org/ofbiz/product/storage/StorageServices.xml" invoke="updateShipmentResiNumber" auth="true"> 
<description>Update a ProductFeature to Product Application</description> 
<attribute name="shipmentResiNumber" type="String" mode="IN" optional="false"/> 
<attribute name="shipmentId" type="String" mode="IN" optional="false"/> 

StorageServices.xml:

+0

您正在使用'GET Method'將數據發送到服務器,並且這些數據將被髮送到服務和'OFBiz'不允許。你必須使用'POST方法'。 –

+0

這是工作,但如何從一次更多地調用服務?如果我使用窗口位置該服務只能工作一次,只有一個元素被更新。我想通過列表的所有元素。如何從一個更多地運行服務?或者有辦法將列表傳遞給服務? – Kevin

+0

試試'service-multi' :) –

回答

0

XML表單就像是FTL相似的,所以你可以使用服務的多,創造的形式來調用服務