Oracle Commerce Droplets

  1. Home
  2. Blog
  3. Oracle Commerce Droplets

Oracle Commerce Droplets

Droplets

Droplet is a Servlet Bean to dynamically generate HTML from a Java Object. It minimizes the amount of Java code that has to appear in HTML and amount of HTML that has to be hard-coded into Java classes.

DAF (Dynamo Application Framework) comes with a set of out-of-the-box droplets that can be used. The user can also create their own custom droplets based on their need.

Writing a Droplet

  • Write a java class extending the atg.servlet.DynamoServlet class.
  • Override service() method and write the required logic here.
  • Identify appropriate Input parameters that will be passed to droplet and OPARAMS the droplet will render and also various output parameters the droplet will set in the request.
  • Write the BeanInfo class and define all the necessary parameters in that.
  • Make droplet into a component using the ATG Component Browser.
  • Embed droplet in a JSP page using the <dsp:droplet> tag and pass the necessary parameters.
  • Use OPARAM tags to mix the HTML content and the dynamic values returned by the droplet.


Below is example of Custom Droplet (Java Code)

class MyDemo extends atg.servlet.DynamoServlet{
    private String demo;
    public void setDemo(String demo){
      this.demo = demo;
    }
    public String getDemo(){
        return this.demo;
    }
    
    public void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse){
      some code....
      pRequest.setParameter("outputDemo" , "DemoName: " + this.getDemo());
      pRequest.serviceParameter("output", pRequest, pResponse);
    }
  }

How to use Droplets in a JSP

Below is how we use it.

<dsp:page>
    some code...
    <dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>
    some code...
    <body>
      <dsp:droplet name="ForEach">
        <dsp:param name="array" value="someList">
        <dsp:oparam name="output">
          <H1><dsp:valueof param="element.demo">
        </dsp:oparam>
      </dsp:droplet>
    </body>
  </dsp:page>

Import statements
<dsp:importbean bean=”/atg/dynamo/droplet/ForEach”/>

Use droplet using following tag
<dsp:droplet name=”ForEach”>

Passing parameters to droplet.
<dsp:param name=”array” value=”someList”>

Let's Share
Show Buttons
Hide Buttons