The jsp
element executes a JSP page and sends output object values to the output ModelMap
. JSPActors
typically write to variables that are mapped by the JSPActor
definition.
Note that existing JSP templates that were created with older versions of the ATG REST framework can be applied to JSPActors
.
Note: If possible, use DropletActors
instead of JSPActors
, as DropletActors
are more modular and do not require configuring a WAR file.
The jsp
element contains the following:
Attribute | Description |
---|---|
| This attribute defines the actor ID, and is used for actor ordering. |
| This is the absolute path of the JSP URL, excluding the context root. |
| The context root of the JSP URL. |
| The value that is written to the HTTP response by the JSP page. You can reference this attribute in an |
| This element defines actors that must be executed prior to the execution of the current actor. There can be multiple |
| This element defines actors that, if present, must be executed prior to the execution of the current actor. There can be multiple |
| This element defines each actor’s input. Actors can have multiple |
| This element defines each actor’s output. |
The following is an example of a jsp
element:
<actor-chain id="shippingMethods"> <jsp url="/atg/commerce/pricing/shippingMethodsActor.jsp" context="DCS"> <!-if true, getPrices will return prices with the shipping methods --> <input name="getPrices" value="${param.getPrices}"> <output name="shippingMethods" value="${shippingMethods}"/> <output name="currencyCode" value="${currencyCode}"/> </jsp> </actor-chain>
The following is an example of the JSP that the element invokes:
<%-- Return available shipping methods, optionally with prices - Optional parameters: getPrices if true, will return prices with the shipping methods - Model output: shippingMethods currencyCode --%> <dsp:page> <dsp:importbean bean="/atg/commerce/pricing/AvailableShippingMethods" /> <dsp:importbean bean="/atg/commerce/pricing/CurrencyCodeDroplet" /> <dsp:importbean bean="/atg/commerce/order/purchase/ShippingGroupFormHandler" /> <dsp:importbean bean="/atg/commerce/ShoppingCart" /> <dsp:importbean bean="/atg/userprofiling/Profile" /> <dsp:getvalueof var="shippingMethodsMap" class="java.core.util.HashMap" scope="request"/> <dsp:getvalueof var="shippingGroup" bean="ShippingGroupFormHandler .firstNonGiftHardgoodShippingGroupWithRels" /> <dsp:getvalueof var="getPrices" param="${param.getPrices}" /> <dsp:droplet name="AvailableShippingMethods"> <dsp:param name="shippingGroup" value="${shippingGroup}" /> <dsp:oparam name="output"> <dsp:getvalueof var="availableShippingMethods" vartype="java.lang.Object" param="availableShippingMethods" /> <c:forEach var="availableShippingMethod" items="${availableShippingMethods}"> <c:set var="shippingPrice" value="null" /> <c:if test="${getPrices == 'true'}"> <%-Determine shipping price for the current shipping method --%> <dsp:droplet name="/atg/store/pricing/PriceShippingMethod" var="priceShippingMethod"> <dsp:param name="shippingMethod" value="${availableShippingMethod}" /> <dsp:oparam name="output"> <c:set target="${shippingMethodsMap}" property="${availableShippingMethod}" value="${priceShippingMethod.shippingPrice}" /> </dsp:oparam> </dsp:droplet> </c:if> </c:forEach> </dsp:oparam> <!-Sets property in the ActorContext --> <c:set name="shippingMethods" value="${shippingMethodsMap}" scope="request" /> </dsp:droplet> <%-Add the currencyCode if returning prices --%> <c:if test="${getPrices == 'true'}"> <dsp:getvalueof var="priceListLocale" vartype="java.lang.String" bean="Profile.priceList.locale" /> <dsp:droplet name="CurrencyCodeDroplet" var="currencyCodeDroplet"> <dsp:param name="locale" value="${priceListLocale}" /> <dsp:oparam name="output"> <!-Sets property in the ActorContext --> <c:set name="currencyCode" value="${currencyCodeDroplet.currencyCode}" scope="request" /> </dsp:oparam> </dsp:droplet> </c:if> </dsp:page>
Example: HTML Output
JSPActors
can output HTML snippets to pass to the client using the response-var
property. For example:
<jsp id="popup" page="/myapp/mypopup.jsp" context="myapp" response-var="popupVar"> <output id="popup" name="popup" value="${popupVar}"/> </jsp>
Example: Migrating Previous REST JSP Templates
To apply previous versions of ATG REST JSP templates to the JSPActors
:
<jsp id="displayCart" page="/orderDetail.jsp" context="mobile" response-var="orderJSON" > <output id="orderOut" name="order" value="${orderJSON}" embed-for-mime-type="application/json"/> </jsp>