Wednesday, January 8, 2014

ATG Droplet - Creating a New Droplet

Droplet Introduction : 

Dynamo Servlet Beans are specialized Nucleus components that can be embedded in our JSPs to display dynamic content.  Droplets are based on MVC2 Dispatcher View (pull based) design pattern.

Writing New Droplet :

CustomDroplet.java

Step 1 :  Create a Java file for example "CustomDroplet" extending DynamoServlet  and override Service method to contruct the logic.

public class CustomDroplet extends DynamoServlet {

public void service(DynamoHttpServletRequest dynamoHttpServletRequest,
            DynamoHttpServletResponse dynamoHttpServletResponse)
            throws ServletException, IOException {


dynamoHttpServletRequest.setParameter("CustomValue", "i am a new user");

dynamoHttpServletRequest.serviceLocalParameter("output",
                dynamoHttpServletRequest, dynamoHttpServletResponse);


}

Here serviceLocalParameter can also be replaceable with serviceParameter. serviceLocalParameter method makes the output parameter available only to that droplet i .e (DynamoServlet  block(as show below) in jsp  and outside the droplet block, the parameter wont be available) and where as serviceParameter makes the output accessible outside the droplet also.

Step 2 : Create a properties file for example "CustomDroplet" with scope as global.

CustomDroplet.properties

$class=com.view.CustomDroplet

Step 3: Access the Droplet in JSP.

 CustomeDropletPage.jsp

<dsp:page>
<dsp:importbean bean="/com/view/CustomDroplet"/>

<dsp:droplet name="CustomDroplet">
    <dsp:oparam name="output">
        New Value: <b><dsp:valueof param="CustomValue">CustomValueis Null</dsp:valueof></b> <br/>
    </dsp:oparam>
</dsp:droplet>

</dsp:page>




1 comment:

  1. Hi

    Thanks for nice explanation.

    Can you help me on ATG set up?

    my email:din.kumar07@gmail.com

    ReplyDelete