Chapter 15. Bidding component 585
Figure 15-33 Choose tag libraries
6. Figure 15-34 on page 586 shows the tag libraries that we need to include in
our JSP file.
586 WebSphere Application Server - Express V6 Developers Guide and Development Examples
Figure 15-34 Selected tag libraries
7. Click Finish.
8. The addBidBoby.jspf is created and opened in the Page Designer. Replace
all the existing code with the code shown in Example 15-3.
Example 15-3 Example code for addBidBody.jspf
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="" prefix="c"%>
<h1>Add a Bid</h1>
<TD width=150>Address:</TD>
Chapter 15. Bidding component 587
<TD width=250><bean:write name="propertyDTO"
property="streetName" /> &nbsp; <bean:write
name="propertyDTO" property="unitNumber" /> <bean:write
name="propertyDTO" property="buildingNumber" /></TD>
<TD>Postal code:</TD>
<TD><bean:write name="propertyDTO" property="postalCode" /></TD>
<TD><bean:write name="propertyDTO" property="municipality" />
<TD><bean:write name="propertyDTO" property="region" /></TD>
<TD><bean:write name="propertyDTO" property="countryCode" /></TD>
<TD><fmt_rt:formatNumber minFractionDigits="2" type="number">
<bean:write name="propertyDTO" property="price" />
<TD>Additional text:</TD>
<TD><bean:write name="propertyDTO" property="additionalText" />
<html:form action="/AddBid">
<TABLE border="0">
<TD><html:text property='sbidDate' /> (yyyy-MM-dd)</TD>
588 WebSphere Application Server - Express V6 Developers Guide and Development Examples
<TH>Bid price</TH>
<TD><html:text property='sbidPrice' /></TD>
<TD><html:submit property="submit" value="Add" /></TD>
<TD><html:reset /></TD>
9. The addBidBody.jspf is quite simple. It has two main purposes:
It displays some details of the property that the user selected to place a
bid against.
It uses an HTML form so the user can enter details of their bid.
10.Save the addBidBody.jspf file.
11.Add the addBidBody.jspf to the body portion of the AddBid.jsp. The easiest
way to do this is to open AddBid.jsp in the design view of the Page Designer,
addBidyBody.jspf from the Project Explorer and drag it onto the body
section of the AddBid.jsp.
12.Save the AddBid.jsp file.
We have now completed the implementation of the presentation layer for the add
bid functionality the bidding component.
15.2.4 Controller layer
Following our top-down approach, the second layer of the bidding component
that we need to implement is the controller layer. Here, we implement the
required action classes.
The controller layer connects the presentation layer with the business logic of the
component, which is implemented in the business facade layer. In effect, the
controller layer accepts a request from the presentation layer, calls the
appropriate method of the business facade layer, stores any results in the
request object, and returns back to the presentation layer for displaying the
results. We describe how to implement the AddBidAction class.
Chapter 15. Bidding component 589
AddBidAction class
The steps to implement this action class are:
1. Using the Project Explorer view navigate to the
SAL404RealtyWeb project,
Java Resources JavaSource and
double-click to open it.
2. Notice that some code has already been created from realizing the relevant
action node while implementing the presentation layer.
3. Add the code highlighted in Example 15-4 to complete the AddBidAction of
the controller layer. Once you have done adding the code save the file.
Example 15-4 Example code for AddBidAction
import java.lang.reflect.InvocationTargetException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
* @version 1.0
* @author
public class AddBidAction extends Action
// Configure Log4J Logger
private static Logger logger = Logger.getLogger(AddBidAction.class);

Get WebSphere Application Server - Express V6 Developers Guide and Development Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.