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


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
Exit mobile version