Chapter 10. Development of XML-bas ed Enterprise applications 253

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 10-15. This function retrieves Enterprise bean by the membership key,
then copy the properties from customer EJB to customer bean.
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 10-16).
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 Generate—>Deploy and RM IC Code.
2. Make sure that the cust omer entity EJB is selected, and click Finish, as in
Figure10-28.