Droplets
/ DSP tag library
Droplets are ATG servlet beans that are used to dynamically
generate HTML. ATG provides numerous droplets to perform lots of common tasks
(e.g. display all the error messages for a form), but it’s possible to write
your own custom ones also. The DSP (dynamo server pages) tag library is
somewhat equivalent to JSTL but with the added ability that they naturally
interact with Nucleus components.
Droplets tend to be a bit verbose. For example, compare the
following piece of hypothetical code to display the contents of a shopping cart
written using ATG droplets with what it might look like if written in a bespoke JEE
application.
<h1>ATG shopping cart example</h1>
<dsp:droplet name="/atg/dynamo/droplet/ForEach"> <dsp:param name="array"
bean="/atg/commerce/ShoppingCart.current.commerceItems" />
<dsp:param name="elementName" value="commerceItem" />
<dsp:oparam name="output">
<dsp:getvalueof var="commerceItemId" param="commerceItem.id" />
<dsp:droplet name="SkuLookupDroplet">
<dsp:param name="id" param="commerceItem.catalogRefId" />
<dsp:param name="elementName" value="sku" />
<dsp:oparam name="output">
<dsp:getvalueof param="sku.displayName" var="skuDisplayName" />
</dsp:oparam>
</dsp:droplet>
<td><dsp:valueof param="skuDisplayName" /> <dsp:valueof
param="commerceItem.priceInfo.amount" converter="currency"
locale="${someCustomlocale}">0.00</dsp:valueof></td>
<td><dsp:a href="deliveryOptions.page"
bean="DeliveryOptionsFormHandler.value.itemId"
value="${commerceItemId}">Delivery Options</dsp:a></td>
</dsp:oparam>
</dsp:droplet>
<h1>Bespoke shopping cart example</h1>
<c:forEach var="commerceItem"
items="${shoppingCart.current.commerceItems}">
<td><customtag:getSkuDisplayName id="${commerceItem.catalogRefId}" />
<fmt:formatNumber type="currency" minFractionDigits="2"
value="${commerceItem.priceInfo.amount}" /></td>
<td><a href="deliveryOptions?itemId=${commerceItem.id}">Delivery Options</a></td>
</c:forEach>
Of course, there is no reason why you can't mix and match tag
libraries and only use the ATG tags and droplets where necessary.
No comments:
Post a Comment