我是编程和宇航员的新手。我需要在javascript函数中调用需要ftl文件参数的服务,我想将参数(resiNumber,shipmentId)传递给该服务并调用该服务。我已尝试使用window.location,但我得到:“数据应通过使其成为请求正文(表单字段)的一部分而不是请求URL来加密”
这是我的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 :(得分:0)
Xml Forms与ftl类似,因此您可以使用service-multi并创建表单来调用服务