Application Platform 10.11 | Application Platform API | webMethods Tag Library for JSP | <webm:switch>
 
<webm:switch>
Use the <webm:switch> tag to execute one of multiple blocks of code, based on the value of a variable in the Integration Server pipeline.
Use <webm:case> to define each value and the associated block of code to execute. Integration Server evaluates <webm:case> tags in the order they appear in the JSP. When a case is true, Integration Server executes the associated block of code, then exits the <webm:switch> structure.
To define a default case to be executed if the specified variable does not exist or if none of the other cases is true, specify a <webm:case> tag with no switch_value. The default case must be the last <webm:case> tag in the <webm:switch> tag.
Syntax
<webm:switch variable="variable">
<webm:case value="switch_value1">block_of_code</webm:case>
[<webm:case value="switch_value2">block_of_code</webm:case>...
<webm:case value="switch_valuen">block_of_code</webm:case>]
[<webm:case>block_of_code</webm:case>]
</webm:switch>
Arguments
Argument
Description
variable
Pipeline variable which value to evaluate.
switch_value
A value of variable that triggers Integration Server to execute the associated block of code. switch_value must match the value of variable exactly. switch_value is case sensitive. For example, FedEx does not match Fedex or FEDEX.
Examples
*To insert different paragraphs into the HTML page produced from the JSP based on the value in the pipeline variable carrier:
<webm:switch variable="carrier">
<webm:case value="FedEx">
<p>Shipped via Federal Express <webm:value="serviceLevel"/>
<webm:value="trackNum"/></p>
</webm:case>
<webm:case value="UPS">
<p>Shipped via UPS <webm:value="serviceLevel"/></p>
</webm:case>
<webm:case value="Freight">
<p>Shipped via <webm:value="transCompany"/><br>
FOB: <webm:value="buyerInfo/streetAddr1"/><br>
<webm:value="buyerInfo/streetAddr2"/><br>
<webm:value="city"/>, <webm:value="state"/>
<webm:value="postalCode"/></p>
</webm:case>
</webm:switch>
*To call different Integration Server services based on the value of the pipeline variable action:
<html>
<head>
<title>Order Tracking System</title>
</head>
<body bgcolor="#FFFFCC">
<h1>Order Tracking System</h1>
<hr>
<webm:switch variable="action">
<webm:case value="shipinfo"/>
<webm:invoke serviceName="orders:getShipInfo"/>
.
.
.
<webm:case value="showorder"/>
<webm:invoke serviceName="orders:orders:getOrderInfo"/>
.
.
.
.
<webm:case value="showinvoice"/>
<webm:invoke serviceName="orders:orders:getInvoices"/>
.
.
.
</webm:switch>
<hr>
<jsp:include page="stdFooter.txt" flush="true"/>
</body>
</html>