I am new in programming and ofbiz. I need to call service that needs parameters from ftl file in javascript function, i want to pass parameters(resiNumber,shipmentId) to that service and call that service. I have try with window.location but i am got: "The data should be encrypted by making it part of the request body (a form field) instead of the request URL"
Here is my ftl code:
<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>
And here is my code in controller.xml for services:
<!-- 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: