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="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<BR>
<h1>Add a Bid</h1>
<HR>
<TABLE>
<TBODY>
<TR>
<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>
</TR>
<TR>
<TD>Postal code:</TD>
<TD><bean:write name="propertyDTO" property="postalCode" /></TD>
</TR>
<TR>
<TD>Municipality:</TD>
<TD><bean:write name="propertyDTO" property="municipality" />
</TD>
</TR>
<TR>
<TD>Region:</TD>
<TD><bean:write name="propertyDTO" property="region" /></TD>
</TR>
<TR>
<TD>Country:</TD>
<TD><bean:write name="propertyDTO" property="countryCode" /></TD>
</TR>
<TR>
<TD>Price:</TD>
<TD><fmt_rt:formatNumber minFractionDigits="2" type="number">
<bean:write name="propertyDTO" property="price" />
</fmt_rt:formatNumber></TD>
</TR>
<TR>
<TD>Additional text:</TD>
<TD><bean:write name="propertyDTO" property="additionalText" />
</TD>
</TR>
</TBODY>
</TABLE>
<BR>
<html:form action="/AddBid">
<TABLE border="0">
<TBODY>
<TR>
<TH>Date</TH>
<TD><html:text property='sbidDate' /> (yyyy-MM-dd)</TD>
</TR>
588 WebSphere Application Server - Express V6 Developers Guide and Development Examples
<TR>
<TH>Bid price</TH>
<TD><html:text property='sbidPrice' /></TD>
</TR>
<TR>
<TD><html:submit property="submit" value="Add" /></TD>
<TD><html:reset /></TD>
</TR>
</TBODY>
</TABLE>
</html:form>
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,
select
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,
choose
Java Resources JavaSource
com.ibm.itso.sal404.bidding.action AddBidAction.java 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
package com.ibm.itso.sal404.bidding.action;
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;
import com.ibm.itso.sal404.bidding.BidManager;
import com.ibm.itso.sal404.bidding.BidSessionData;
import com.ibm.itso.sal404.bidding.dto.BidDTO;
import com.ibm.itso.sal404.bidding.form.BidForm;
import com.ibm.itso.sal404.common.exception.ApplicationException;
import com.ibm.itso.sal404.propertycatalog.dto.PropertyDTO;
import com.ibm.itso.sal404.user.UserSessionData;
/**
* @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.