IBM Support

How to add a loop counter inside a jsp to retrieve data from multiple rows?

Question & Answer


Question

How to add a loop counter inside a jsp to retrieve data from multiple rows?

Cause

Answer

The JSP need to have a counter within the loop that reads the data from the console and bind it to the XML. Counter is required for assigning the values fetched by each loop cycle to different variables (Eg: shipment_1,shipment_2...) which populate it into the XML. Please refer for information on how the 'counter' is used in the 'Development Guide' section 4.22.3, you can also go through "YFS_HOME\webpages\om\order\detail\order_detail_orderlines.jsp" page to check usage example.

Example of JSP that worked:
<%@include file="/yfsjspcommon/yfsutil.jsp"%> <%@ include file="/console/jsp/modificationutils.jsp" %> <script language="javascript" src="/yantra/console/scripts/tools.js"></script> <% String recNode = ""; String pickupStopNode = ""; String dropoffStopNode = ""; %>

<thead> </thead> <yfc:loopXML name="Load" binding="xml:/Load/LoadShipments/@LoadShipment" id="LoadShipment"> <yfc:makeXMLInput name="loadShipmentStopKey" > <yfc:makeXMLKey binding="xml:/LoadShipment/PickupStop/@LoadStopKey" value="xml:/LoadShipment/PickupStop/@LoadStopKey" /> <yfc:makeXMLKey binding="xml:/LoadShipment/DropoffStop/@LoadStopKey" value="xml:/LoadShipment/DropoffStop/@LoadStopKey" /> </yfc:makeXMLInput> <yfc:makeXMLInput name="LoadShipmentKey" > <yfc:makeXMLKey binding="xml:/Shipment/LoadShipments/LoadShipment/@LoadShipmentKey" value="xml:/LoadShipment/@LoadShipmentKey" /> <yfc:makeXMLKey binding="xml:/Shipment/LoadShipments/LoadShipment/@ShipmentKey" value="xml:/LoadShipment/@ShipmentKey" /> <yfc:makeXMLKey binding="xml:/Shipment/@EnterpriseCode" value="xml:/Load/@EnterpriseCode" /> <yfc:makeXMLKey binding="xml:/Shipment/@LoadKey" value="xml:/Load/@LoadKey" /> <yfc:makeXMLKey binding="xml:/Shipment/@ShipmentKey" value="xml:/LoadShipment/@ShipmentKey" /> </yfc:makeXMLInput> <input type="hidden" name="ShipmentKey_<%=LoadShipmentCounter%>" value='<%=resolveValue("xml:/LoadShipment/Shipment/@ShipmentKey")%>' /> <input type="hidden" <%=getTextOptions("xml:/Loads/Load/LoadShipments/LoadShipment/Shipment_" + LoadShipmentCounter + "/@ShipmentKey", "xml:/LoadShipment/Shipment/@ShipmentKey")%> /> </yfc:loopXML>
<input type="checkbox" name="checkbox" value="checkbox" onclick="doCheckAll(this);"/> <yfc:i18n>Shipment_#</yfc:i18n> <input type="hidden" class="unprotectedinput" <%=getTextOptions("xml:/Shipment/DeliveryPlan/@DeliveryPlanNo", "xml:/Load/DeliveryPlan/@DeliveryPlanNo")%>/> <input type="hidden" class="unprotectedinput" <%=getTextOptions("xml:/Shipment/@EnterpriseCode", "xml:/Load/DeliveryPlan/@EnterpriseCode")%>/> <yfc:i18n>Status</yfc:i18n> <yfc:i18n>Pieces</yfc:i18n> <yfc:i18n>Ship_Date</yfc:i18n> <yfc:i18n>Origin</yfc:i18n> <yfc:i18n>Destination</yfc:i18n> <yfc:i18n>Pickup_Stop_At</yfc:i18n> <yfc:i18n>Dropoff_Stop_At</yfc:i18n> <yfc:i18n>Total_Weight</yfc:i18n> <yfc:i18n>Total_Volume</yfc:i18n>
<input type="checkbox" value='<%=getParameter("LoadShipmentKey")%>' name="checkEntityKey" yfsTargetEntity="<%=getEntityIDForLink("L01", getValue("LoadShipment", "xml:/LoadShipment/Shipment/@DocumentType"))%>"/> <yfc:makeXMLInput name="ShipmentKey" > <yfc:makeXMLKey binding="xml:/Shipment/@ShipmentKey" value="xml:/LoadShipment/Shipment/@ShipmentKey" /> </yfc:makeXMLInput> <% if(showShipmentNo(resolveValue("xml:/Shipment/@EnterpriseCode"))) { %> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@ShipmentNo"/> <% } else { %> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@ShipmentNo"/> <%}%> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/Status/@Description"/> <input type="text" <%=getTextOptions("xml:/Loads/Load/LoadShipments/LoadShipment/Shipment_" + LoadShipmentCounter + "/@NumOfCartons", "xml:/LoadShipment/Shipment/@NumOfCartons")%>/> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@ShipDate"/> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@ShipNode"/> <% recNode= getValue("LoadShipment", "xml:/LoadShipment/Shipment/@ReceivingNode"); if (!isVoid(recNode)) { %> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@ReceivingNode"/> <%} else { %> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/ToAddress/@City"/> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/ToAddress/@State"/> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/ToAddress/@Country"/> <%}%> <% pickupStopNode = getValue("LoadShipment", "xml:/LoadShipment/PickupStop/@StopNode"); if (!isVoid(pickupStopNode)) { %> <yfc:getXMLValue binding="xml:/LoadShipment/PickupStop/@StopNode"/> <%} else { %> <yfc:getXMLValue binding="xml:/LoadShipment/PickupStop/StopAddress/@City"/> <yfc:getXMLValue binding="xml:/LoadShipment/PickupStop/StopAddress/@State"/> <yfc:getXMLValue binding="xml:/LoadShipment/PickupStop/StopAddress/@Country"/> <%}%> <% dropoffStopNode = getValue("LoadShipment", "xml:/LoadShipment/DropoffStop/@StopNode"); if (!isVoid(dropoffStopNode)) { %> <yfc:getXMLValue binding="xml:/LoadShipment/PickupStop/@StopNode"/> <%} else { %> <yfc:getXMLValue binding="xml:/LoadShipment/DropoffStop/StopAddress/@City"/> <yfc:getXMLValue binding="xml:/LoadShipment/DropoffStop/StopAddress/@State"/> <yfc:getXMLValue binding="xml:/LoadShipment/DropoffStop/StopAddress/@Country"/> <%}%> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@TotalWeight"/> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@TotalWeightUOM"/> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@TotalVolume"/> <yfc:getXMLValue binding="xml:/LoadShipment/Shipment/@TotalVolumeUOM"/>

[{"Product":{"code":"SS6PEW","label":"IBM Sterling Order Management"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Historical Number

PRI49369

Product Synonym

[<p><b>]Fact[</b><p>];

Document Information

Modified date:
16 June 2018

UID

swg21547348