
10.3.4 Retrieval function
This registration application does not offer the retrieval function. To add the retrieval function to CustomerXML class, we add retrieve method as Example
Example 10-15 Retrieval function
protected void retrieve(Long membership) throws RemoteException, FinderException
{
CustomerFactory factory = new CustomerFactory(); registration.Customer ejbean = factory.findByPrimaryKey(new
CustomerKey(membership));
setFirstName(ejbean.getFirstName());
setLastName(ejbean.getLastName());
setEmail(ejbean.getEmail());
setMembership(membership);
}
In the next chapter, we show how to include the retrieve function into the registration form. At this time, we add a statement to confirm the registration. In the doPost method, we retrieve the customer using the membership key just after create (see Example
Example 10-16 Confirming the creation
try{
xml.retrieve(new Long(request.getParameter("membership"))); showPage(resultStylesheet, response);
}catch(FinderException remoteEx){
}
10.4 Application deployment and testing
We are now ready to generate the deployed code to support the execution on WebSphere test environment:
1.Switch to the J2EE Hierarchy view, select the CustomerInfoEJB under the EJB Modules, and select
2.Make sure that the customer entity EJB is selected, and click Finish, as in Figure