When the customer chooses a link from the order history page to view a single particular order (such as #o12345), he sees a page of detailed information about that order with a URL like this: http://my.bikestore.com/path/order.jsp?orderId=o12345
. The orderId
parameter is generated by setting a parameter between the <dsp:a>
and </dsp:a>
tags of the link on order_history.jsp
like this:
<dsp:a href="order.jsp"> <dsp:param name="orderId" param="element.id"/> #<dsp:valueof param="element.id">no order number</dsp:valueof></dsp:a>
The customer is then shown the status and history of a single order (order.jsp
with the information of order number that corresponds to orderId
). In the JSP code snippet from order.jsp
below, instead of being passed explicitly as a parameter to the OrderLookup
servlet bean, orderId
is set by the link from the order history page.
<dsp:droplet name="/atg/commerce/order/OrderLookup"> <dsp:oparam name="error"> <p> <span class=profilebig>ERROR: <dsp:valueof param="errorMsg">no error message</dsp:valueof> </span> <p> </dsp:oparam> <dsp:oparam name="output"> <dsp:setvalue paramvalue="result" param="order"/> <p> <span class=profilebig>order #<dsp:valueof param="order.id">no order id</dsp:valueof></span> <p> <table cellspacing=0 cellpadding=0 border=0> <!-- Setup gutter and make space --> <tr> <td><dsp:img height="1" width="100" src="../images/d.gif"/><br></td> <td> </td> <td><dsp:img height="1" width="400" src="../images/d.gif"/></td> </tr> <dsp:droplet name="Switch"> <dsp:param name="value" param="order.stateAsString"/> <dsp:oparam name="NO_PENDING_ACTION"> <tr valign=top> <td> <span class=help>Gosh. You should have this one by now.</span> </td> <td></td> <td> <table width=100% cellpadding=0 cellspacing=0 border=0> <tr><td class=box-top-profile>Order status</td></tr></table> <p> This order was placed on <dsp:valueof date="MMMMM d, yyyy" param="order.submittedDate"/> and shipped on <dsp:valueof date="MMMMM d, yyyy" param="order.completedDate"/>. <p> If there is a problem with this order, please <dsp:a href="contact_customer_service.jsp">contact a customer service representative</dsp:a>. <p> <br> </td> </tr> </dsp:oparam> <dsp:oparam name="default"> <tr valign=top> <td> <span class=help>Since this order has not yet shipped, you may still change it.</span> </td> <td></td> <td> <table width=100% cellpadding=0 cellspacing=0 border=0> <tr><td class=box-top-profile>Order status</td></tr></table> <p> This order was placed on <dsp:valueof date="MMMMM d, yyyy" param="order.submittedDate"/>. <br> Its status is <dsp:valueof param="order.stateAsString">UNKNOWN STATUS</dsp:valueof>. <br> <p> > <dsp:a href="cancel_order.jsp"> <dsp:param name="orderId" param="order.id"/> cancel the order</dsp:a><br> <p> To make any other changes to this order, please <dsp:a href="contact_customer_service.jsp">contact a customer service representative</dsp:a>. </span> <p> <br> </td> </tr> </dsp:oparam> </dsp:droplet> <tr valign=top> <td> <span class=help>This is the contents of the order.</span> </td> <td></td> <td> <table width=100% cellpadding=0 cellspacing=0 border=0> <tr><td class=box-top-profile>Order details</td></tr></table> <p> <table cellspacing=2 cellpadding=0 border=0> <tr><td></td><td> </td><td></td><td> </td><td></td></tr> <tr valign=top> <td colspan=3> <b>Order # <dsp:valueof param="order.id">no order id</dsp:valueof></b><br> <dsp:valueof date="h:mma MMMMM d, yyyy" param="order.submittedDate"/><br> Sales: orders@example.com </td> <td colspan=2></td> </tr> <tr><td colspan=5><hr size=0></td></tr> <tr valign=top> <td colspan=3> <dsp:getvalueof id="pval0" param="order" idtype=" atg.commerce.order.Order"> <dsp:include page="OrderBillingInfo.jsp" flush="true"> <dsp:param name="order" value="<%=pval0%>"/></dsp:include></dsp:getvalueof> </td> <td colspan=2></td> </tr> <tr><td colspan=5><hr size=0></td></tr> <dsp:getvalueof id="pval0" param="order" idtype=" atg.commerce.order.Order"> <dsp:include page="OrderShippingInfo.jsp" flush="true"> <dsp:param name="order" value="<%=pval0%>"/></dsp:include></dsp:getvalueof> <tr><td colspan=5><hr size=0></td></tr> </table> </td> </tr> </table> <P> </dsp:oparam> </dsp:droplet>
The OrderLookup
servlet bean puts the order into the result
parameter. Because we thought it would be clearer, we renamed the parameter order
using the setvalue
statement of <dsp:setvalue param="order" paramvalue="result"/>
. Then any of the order properties can be accessed using order.<propertyname>
.
Because order.jsp
contains so much information, the JSP can become difficult to read. For easier reading we separated out the OrderBillingInfo.jsp
and OrderShippingInfo.jsp
fragments and included them in order.jsp
using:
<dsp:include page="filename.jsp" flush="true"></dsp:include>
These pages display details of the order’s shipping and billing information.
There is no technical reason for separating the JSP fragments OrderBillingInfo.jsp
and OrderShippingInfo.jsp
rather than including them inline in order.jsp
. However, it is often easier to manage a large number of small JSP files than a small number of larger JSP files.
It is important to remember that the OrderLookup
servlet bean has a security feature that enables a customer to look up only his own orders. If you would like disable this security feature so that anyone can look at any order, you can set the property OrderLookup.enableSecurity=false
.