OrderDroplet.java
Below is the sample atg droplet, which will accept the Profile object as an input parameter and sets the Orders for the
profile in the output parameter.
/*
* Created on Aug 11, 2005
*/
package com.droplet;
import java.io.IOException;
import javax.servlet.ServletException;
import atg.servlet.DynamoHttpServletRequest;
import atg.servlet.DynamoHttpServletResponse;
import atg.servlet.DynamoServlet;
import com.profile.Profile;
public class OrdersDroplet extends DynamoServlet
{
private Manager manager;
public void service(DynamoHttpServletRequest request, DynamoHttpServletResponse response)
throws ServletException, IOException
{
try
{
Profile profile = (Profile) request.getObjectParameter("profile");
if (profile != null)
{
request.setParameter("orders", getManager().getOrders(profile));
request.serviceLocalParameter("output", request, response);
}
}
catch (Exception e)
{
if (isLoggingError())
{
logError(e);
}
}
}
/**
* @return Returns the Manager.
*/
public Manager getManager()
{
return manager;
}
/**
* @param Manager The Manager to set.
*/
public void setManager(Manager manager)
{
this.manager = manager;
}
}
droplet_test.jsp
Below is the sample jsp which will get the profileID from the request get parameter and converts it into a Profile Object
and pass it to the droplet to list all orders for that profile
<%@ taglib prefix="dsp" uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0"%>
<dsp:importbean bean="/atg/targeting/RepositoryLookup"/>
<dsp:importbean bean="/atg/dynamo/droplet/TableForEach"/>
<dsp:importbean bean="/droplet/OrderDroplet"/>
<dsp:page>
<dsp:droplet name="RepositoryLookup">
<dsp:param name="repository" bean="/repository/Profile"/>
<dsp:param name="itemDescriptor" value="profile"/>
<dsp:param name="id" param="profileId"/>
<dsp:oparam name="output">
<dsp:droplet name="TableForEach">
<dsp:param name="array" param="orders"/>
<dsp:param name="elementName" value="order"/>
<dsp:param name="numColumns" value="3"/>
<dsp:oparam name="outputStart"><table border=1></dsp:oparam>
<dsp:oparam name="outputEnd"></table></dsp:oparam>
<dsp:oparam name="outputRowStart"><tr></dsp:oparam>
<dsp:oparam name="outputRowEnd"></tr></dsp:oparam>
<dsp:oparam name="output">
<td><dsp:valueof param="order.orderID"/></td>
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>
</dsp:page>
No comments:
Post a Comment