4 Replies Latest reply on Aug 8, 2013 10:47 PM by Nagarajan Seshadri

    Passing dynamic list / array of values to Droplet


      I want to know what's the best way to pass list of values as array or list to a droplet.

      Any examples here?

        • 1. Re: Passing dynamic list / array of values to Droplet
          Ricky S

          u can refer to the following droplet , it uses both list and array


          <droplet bean="/atg/commerce/pricing/PriceEachItem">

          <param name="items" value="param:product.childSKUs">

          <!-- the product param is already defined in this scope so we do not need to set it -->

          <oparam name="output">

            <!-- Now iterate over each of the CommerceItems to display the prices -->

            <droplet bean="/atg/dynamo/droplet/ForEach">

            <param name="array" value="param:element">

            <param name="elementName" value="pricedItem">

            <oparam name="output">

            <valueof param="pricedItem.auxiliaryData.catalogRef.displayName"></valueof> -

            <!-- Toggle a different display depending if the item is on sale or not -->

            <droplet bean="Switch">

            <param name="value" value="param:pricedItem.priceInfo.onSale">

            <oparam name="false">

            <valueof param="pricedItem.priceInfo.amount" currency>no price</valueof>


            <oparam name="true">

            List price for <valueof param="pricedItem.priceInfo.listPrice" currency>no price</valueof>

            on sale for <valueof param="pricedItem.priceInfo.salePrice" currency></valueof>!







          • 2. Re: Passing dynamic list / array of values to Droplet

            Thanks for the reply. What I meant is to construct the list/array parameters in the jsp. Not to pass an existing list /array to the jsp.

            For example, I should be able to pass firstName, lastName, zipCode, address1 etc from the jsp as a list to the droplet with a name say 'param'

            Inside the droplet it should be accessible as param[0], param[1] or through param.iterator()

            • 3. Re: Passing dynamic list / array of values to Droplet

              Hi Jagadeesh,

              In above drooplet childSKUs in a collection that we are passing as input param and rendering in droplet. You can follow the same approach and you can pass your own values like, you can maitain a map/set/list/array type property of a component and pass to droplet as a bean value.

              There may be better approach of your requirement. So  is it possible to elaborate the requirement?



              • 4. Re: Passing dynamic list / array of values to Droplet
                Nagarajan Seshadri

                Whats the need for passing totally different kind of attributes to the droplet as an array ? Isnt it a bad coding practice? It would be more of an assumption that param[0] is firstname, param[0] is lastname etc.,instead it would be good pass them as individual params themselves to the droplet


                <dsp:param name="firstname" value="whatever"/>

                <dsp:param name="lastname" value="somethingelse"/?


                etc., and fetch them as different variables in Droplet. Or the component which provides the firstName, lastName, etc to the JSP - may be a Formhandler or another Droplet or a repository can be modified to also provide a list / array that you want so that you can easily pass it on to your new Droplet as a param. FYI - In case of repository you can write a custom property descriptor which can return an array