1 / 59

Professional Java Server Programming J2EE Edition

Professional Java Server Programming J2EE Edition. Chapter 22 : Development and Deployment Roles. Robert David Cowan CS486 April 9, 2001. Model-View-Controller Design. Models. Views View1.jsp View2.jsp View3.jsp. Controller Main.jsp. Browser Client. Manufacturing App Design.

gari
Télécharger la présentation

Professional Java Server Programming J2EE Edition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Professional Java Server Programming J2EE Edition Chapter 22 : Development and Deployment Roles Robert David Cowan CS486 April 9, 2001

  2. Model-View-Controller Design Models Views View1.jsp View2.jsp View3.jsp Controller Main.jsp Browser Client

  3. Manufacturing App Design Models ManageOrdersManufacture ModelManager (proxy) Views createproduct.jsp createrouting.jsp ….and others Controller RequestProcessor Main.jsp Browser Client

  4. Choices.jsp • Choose one of the following actions: • Create a sample product • Place a sample order • Manage orders • Manufacture a product for an order

  5. Code for Choices.jsp Choices <html> <head> <title>Wrox Sample Code / J2EE</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p>Choose one of the following actions:</p> <ul> <li><a href="createproduct">Create a sample product</a></li> <li><a href="placeorder">Place a sample order</a></li> <li><a href="manageorders?ordertype=openorders">Manage orders</a></li> <li><a href="manufacturechoose">Manufacture a product for an order</a></li> </ul> <p>&nbsp;</p> <p>&nbsp; </p> </body> </html>

  6. Code for Main.jsp <%-- % The entry point for the manufacturing application --%> <jsp:useBean id="modelManager" class="ModelManager" scope="session" > <% modelManager.init(config.getServletContext(), session); %> </jsp:useBean> <jsp:useBean id="rp" class="RequestProcessor" scope="session" > <% rp.init(config.getServletContext(), session); %> </jsp:useBean> Model and request processor @ session scope.

  7. Code for Main.jsp (cont.) Forward request to RequestProcessor.java (class) = update model and return next view. <% String targetView = rp.processRequest(request); Dispatch the request to the appropriate view. getServletConfig().getServletContext(). getRequestDispatcher(targetView).forward(request, response); %>

  8. Code for RequestProcessor.javaclass import java.text.DateFormat; import java.util.Date; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import factory.manage_orders.NoSuchOrderException; import factory.manage_orders.NoSuchProductException; import factory.manage_orders.DuplicateOrderException; import factory.manufacture.BadStatusException; import factory.order.OrderNotCancelableException; public class RequestProcessor { private ModelManager mm; private HttpSession session; private ServletContext context; private String stackURL; private DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);

  9. Code for RequestProcessor.java (cont.) Copy model proxy public void init(ServletContext context, HttpSession session) { this.session = session; this.context = context; mm = (ModelManager)session.getAttribute("modelManager"); } public String processRequest(HttpServletRequest req) { String selectedURL = req.getPathInfo(); if ((selectedURL == null) || selectedURL.equals( ScreenNames.CHOICES )) { return ScreenNames.CHOICES_URL; } else if (selectedURL.equals( ScreenNames.CHOOSE_FOR_MANUFACTURE )) { String cellName = mm.getCurrentCell(); if (cellName == null) { // requires "log on" stackURL = ScreenNames.CHOOSE_FOR_MANUFACTURE_URL; return ScreenNames.CHOOSE_CELL_URL; } Processing request

  10. Code for RequestProcessor.java(cont.) } else if (selectedURL.equals( ScreenNames.CELL_CHOSEN )) { String cellName = req.getParameter( ScreenNames.CELL_PARAM ); mm.setCurrentCell( cellName ); return stackURL; } else if (selectedURL.equals( ScreenNames.PRODUCT_CREATED )) { String prodID = req.getParameter( ScreenNames.PRODUCT_ID_PARAM ); String prodName = req.getParameter( ScreenNames.PRODUCT_NAME_PARAM ); mm.createProduct( prodID, prodName ); return ScreenNames.CREATE_ROUTING_URL; } else if (selectedURL.equals( ScreenNames.CREATE_ROUTING )) { return ScreenNames.CREATE_ROUTING_URL; } else if (selectedURL.equals( ScreenNames.ROUTING_CREATED )) { String sequence = req.getParameter( ScreenNames.ROUTING_SEQUENCE_PARAM ); String action = req.getParameter( ScreenNames.ROUTING_ACTION_STEP_PARAM ); mm.addRouting( Integer.parseInt(sequence), action ); return ScreenNames.CREATE_ROUTING_URL;

  11. Code for RequestProcessor.java(cont.) } else if (selectedURL.equals( ScreenNames.CANCEL_ORDER )) { String salesDivision = req.getParameter( ScreenNames.SALES_DIVISION_PARAM ); String orderNumber = req.getParameter( ScreenNames.ORDER_NUMBER_PARAM ); String orderType = (req.getParameter(ScreenNames.ORDER_TYPE_PARAM)); try { System.out.println("Request Processor cancel order"); mm.cancelOrder( Integer.parseInt(salesDivision), Integer.parseInt(orderNumber) ); prepareManageOrdersRequest( orderType, req ); return ScreenNames.MANAGE_ORDERS_URL; } catch (OrderNotCancelableException once) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "This order is not cancelable." ); return ScreenNames.MESSAGE_URL; } catch (NoSuchOrderException nsoe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "This order does not exist." ); return ScreenNames.MESSAGE_URL; }

  12. Code for RequestProcessor.java(cont.) } else if (selectedURL.equals( ScreenNames.MANAGE_ORDERS )) { String orderType = (req.getParameter(ScreenNames.ORDER_TYPE_PARAM)); prepareManageOrdersRequest( orderType, req ); return ScreenNames.MANAGE_ORDERS_URL; } else if (selectedURL.equals( ScreenNames.PLACE_ORDER )) { return ScreenNames.PLACE_ORDER_URL; } else if (selectedURL.equals( ScreenNames.ORDER_PLACED )) { try { String salesDiv = req.getParameter( ScreenNames.ORDER_SALES_DIV_PARAM ); String orderNum = req.getParameter( ScreenNames.ORDER_NUM_PARAM ); String productID = req.getParameter( ScreenNames.ORDER_PROD_PARAM ); String dateDueString = req.getParameter( ScreenNames.ORDER_DUE_DATE_PARAM ); Date dateDue = dateFormat.parse( dateDueString ); mm.placeOrder(Integer.parseInt(salesDiv), Integer.parseInt(orderNum), productID, dateDue );

  13. Code for RequestProcessor.java(cont.) req.setAttribute(ScreenNames.MESSAGE_ATTRIB, "Thank you for placing this order." ); } catch (NoSuchProductException nspe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "There is no such product." ); } catch (DuplicateOrderException doe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "There is already an order in that sales division with that number." ); } catch (java.text.ParseException pe) { req.setAttribute( ScreenNames.MESSAGE_ATTRIB, "That is not a valid date." ); } return ScreenNames.MESSAGE_URL; } else if (selectedURL.equals( ScreenNames.ROUTE_FOR_MANUFACTURE )) { if (mm.hasNextRouting()) return ScreenNames.ROUTE_FOR_MANUFACTURE_URL; else return ScreenNames.SHIP_URL; } else if (selectedURL.equals( ScreenNames.SHIP_PRODUCT )) { String loadingDock = req.getParameter(

  14. Code for RequestProcessor.java(cont.) String loadingDock = req.getParameter( ScreenNames.SHIP_LOADING_DOCK_PARAM ); String carrier = req.getParameter(ScreenNames.SHIP_METHOD_PARAM ); mm.shipProduct( carrier, Integer.parseInt(loadingDock) ); return ScreenNames.CHOICES_URL; } else { return ScreenNames.CHOICES_URL; } }

  15. Code for RequestProcessor.java(cont.)prepareManageOrdersRequest Helper method to abstract out some functionality used twice private void prepareManageOrdersRequest(String orderType, HttpServletRequest req) { if (orderType.equals(ScreenNames.ORDER_TYPE_OVERDUE)) { req.setAttribute(ScreenNames.ORDER_URL_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE); req.setAttribute(ScreenNames.ORDER_ALT_URL_ATTRIB, ScreenNames.ORDER_TYPE_OPEN); req.setAttribute(ScreenNames.ORDER_ALT_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OPEN_TEXT); req.setAttribute(ScreenNames.ORDER_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE_TEXT);

  16. Code for RequestProcessor.java(cont.)prepareManageOrdersRequest } else // orderType.equals(ScreenNames.ORDER_TYPE_OPEN) ) { req.setAttribute(ScreenNames.ORDER_URL_ATTRIB, ScreenNames.ORDER_TYPE_OPEN); req.setAttribute(ScreenNames.ORDER_ALT_URL_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE); req.setAttribute(ScreenNames.ORDER_ALT_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OVERDUE_TEXT); req.setAttribute(ScreenNames.ORDER_VIEW_ATTRIB, ScreenNames.ORDER_TYPE_OPEN_TEXT); } } }

  17. Code for ScreenNames.javaclass Constants defined public interface ScreenNames { // paths public static final String CHOICES = "/choices"; public static final String CREATE_PRODUCT = "/createproduct"; public static final String CREATE_ROUTING = "/createrouting"; public static final String MANAGE_ORDERS = "/manageorders"; public static final String CHOOSE_FOR_MANUFACTURE = "/manufacturechoose"; public static final String ROUTE_FOR_MANUFACTURE = "/manufactureroute"; public static final String PLACE_ORDER = "/placeorder"; public static final String ORDER_PLACED = "/order_placed"; public static final String PRODUCT_CREATED = "/product_created"; public static final String ROUTING_CREATED = "/routing_created"; public static final String ORDER_CHOSEN = "/order_chosen"; public static final String CANCEL_ORDER = "/cancelorder"; public static final String CELL_CHOSEN = "/cell_chosen"; public static final String SHIP_PRODUCT = "/ship_product";

  18. Code for ScreenNames.java (cont.) // jsps public static final String CHOICES_URL = "/choices.jsp"; public static final String CREATE_PRODUCT_URL = "/createproduct.jsp"; public static final String CREATE_ROUTING_URL = "/createrouting.jsp"; public static final String MANAGE_ORDERS_URL = "/manageorders.jsp"; public static final String CHOOSE_FOR_MANUFACTURE_URL = "/manufacturechoose.jsp"; public static final String ROUTE_FOR_MANUFACTURE_URL = "/manufactureroute.jsp"; public static final String PLACE_ORDER_URL = "/placeorder.jsp"; public static final String MESSAGE_URL = "/message.jsp"; public static final String CHOOSE_CELL_URL = "/cellid.jsp"; public static final String SHIP_URL = "/ship.jsp";

  19. Code for ScreenNames.java(cont.) // parameters public static final String ORDER_TYPE_PARAM = "ordertype"; public static final String ORDER_VIEW_ATTRIB = "order_view"; public static final String ORDER_ALT_VIEW_ATTRIB = "order_alt_view"; public static final String ORDER_ALT_URL_ATTRIB = "order_alt_url"; public static final String ORDER_URL_ATTRIB = "order_url"; public static final String ORDER_TYPE_OPEN = "openorders"; public static final String ORDER_TYPE_OVERDUE = "overdueorders"; public static final String ORDER_TYPE_OPEN_TEXT = "open orders"; public static final String ORDER_TYPE_OVERDUE_TEXT = "overdue orders"; public static final String SALES_DIVISION_PARAM = "salesdivision"; public static final String ORDER_NUMBER_PARAM = "ordernumber"; public static final String MESSAGE_ATTRIB = "message";

  20. Code for ScreenNames.java(cont.) public static final String PRODUCT_ID_PARAM = "product_id"; public static final String PRODUCT_NAME_PARAM = "product_name"; public static final String ROUTING_SEQUENCE_PARAM = "sequence"; public static final String ROUTING_ACTION_STEP_PARAM = "routing"; public static final String ORDER_SALES_DIV_PARAM = "sales_div"; public static final String ORDER_NUM_PARAM = "order_num"; public static final String ORDER_PROD_PARAM = "prod"; public static final String ORDER_DUE_DATE_PARAM = "due_date"; public static final String CELL_PARAM = "cell"; public static final String SHIP_METHOD_PARAM = "shipping_company"; public static final String SHIP_LOADING_DOCK_PARAM = "loading_dock"; }

  21. Code for ModelManager.javaclass Web-tier proxy for EJB-tier import javax.ejb.EJBException; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import javax.servlet.http.HttpSession; import javax.servlet.ServletContext; import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import factory.manage_orders.DuplicateOrderException; import factory.manage_orders.OpenOrderView; import factory.manage_orders.OverdueOrderView; import factory.manage_orders.ManageOrders; import factory.manage_orders.ManageOrdersHome; import factory.manage_orders.NoSuchOrderException; import factory.manage_orders.NoSuchProductException; import factory.manufacture.BadStatusException; import factory.manufacture.Manufacture; import factory.manufacture.ManufactureHome; import factory.order.OrderNotCancelableException;

  22. Code for ModelManager.java (cont.) public class ModelManager { private ServletContext context; private HttpSession session; Maintain references to session bean façade. Save persistent Manufacture (stateful) ManageOrder could be reaquired each time for load balancing. private ManageOrders manageOrders; private Manufacture manufacture; private String currentCellID; private String currentProductID; public void init(ServletContext context, HttpSession session) { this.session = session; this.context = context; manageOrders = getManageOrdersEJB(); }

  23. Code for ModelManager.java (cont.) public void createProduct( String productID, String productName ) { try { manageOrders.createProduct( productID, productName ); currentProductID = productID; } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); } } public String getCurrentCell() { return currentCellID; } public void setCurrentCell( String currentCell ) { currentCellID = currentCell; } public String getCurrentProductID() { return currentProductID; }

  24. Code for ModelManager.java (cont.) public void addRouting( int sequence, String action ) { try { manageOrders.addRoutingInstruction( currentProductID, sequence, action ); } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); } } public void placeOrder(int salesDivision, int orderNumber, String product, Date dateDue ) throws NoSuchProductException, DuplicateOrderException { try { manageOrders.placeOrder( salesDivision, orderNumber, product, dateDue ); } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); } }

  25. Code for ModelManager.java (cont.) public void cancelOrder( int salesDivision, int orderNumber ) throws NoSuchOrderException, OrderNotCancelableException { try { manageOrders.cancelOrder( salesDivision, orderNumber ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } } public synchronized Iterator getOrdersToManufacture() { try { LinkedList list = new LinkedList(); manufacture = getManufactureEJB(); OpenOrderView[] openOrders = manufacture.getOpenOrders(); for (int iter=0; iter<openOrders.length; iter++) { list.add( new OrderView(openOrders[iter]) ); } return list.iterator(); } catch (java.rmi.RemoteException re ) { throw new EJBException( re ); } } synchronization of stateful session bean else illegal multiple concurrent access, stateless does not need it as each access would be directed to a different EJB instance

  26. Code for ModelManager.java (cont.) public synchronized void selectForManufacture(int salesDiv, int orderNum ) throws NoSuchOrderException, BadStatusException { try { manufacture.selectForManufacture( salesDiv, orderNum ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } } public synchronized boolean hasNextRouting() { try { return manufacture.hasNextRouting(); } catch (factory.manufacture.NoSelectionException nse) { throw new EJBException( nse ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } }

  27. Code for ModelManager.java (cont.) public synchronized String getNextRouting() { try { return manufacture.getNextRouting(); } catch (factory.manufacture.NoSelectionException nse) { throw new EJBException( nse ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } } public synchronized void shipProduct( String carrier, int loadingDock ) { try { manufacture.ship( carrier, loadingDock ); } catch (factory.manufacture.NoSelectionException nse) { throw new EJBException( nse ); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } }

  28. Code for ModelManager.java (cont.) public Iterator getOrders(String type) { try { LinkedList list = new LinkedList(); if (type.equals( ScreenNames.ORDER_TYPE_OPEN_TEXT )) { OpenOrderView[] openOrders = manageOrders.getSchedulableOrders(); for (int iter=0; iter<openOrders.length; iter++) { list.add( new OrderView(openOrders[iter]) ); } } else if (type.equals( ScreenNames.ORDER_TYPE_OVERDUE_TEXT )) { OverdueOrderView[] overdueOrders = manageOrders.getOverdueOrders(); for (int iter=0; iter<overdueOrders.length; iter++) { list.add( new OrderView(overdueOrders[iter]) ); } } else throw new IllegalStateException(); return list.iterator(); } catch (java.rmi.RemoteException re) { throw new EJBException( re ); } }

  29. Code for ModelManager.java (cont.) helper methods private ManageOrders getManageOrdersEJB() { try { InitialContext initial = new InitialContext(); Object objref = initial.lookup( "java:comp/env/ejb/ManageOrders" ); ManageOrdersHome home = (ManageOrdersHome) PortableRemoteObject.narrow( objref, ManageOrdersHome.class ); return home.create(); } catch (NamingException ne) { throw new EJBException(ne); } catch (java.rmi.RemoteException re) { throw new EJBException(re); } catch (javax.ejb.CreateException ce) { throw new EJBException(ce); } }

  30. Code for ModelManager.java (cont.) private Manufacture getManufactureEJB() { try { InitialContext initial = new InitialContext(); Object objref = initial.lookup( "java:comp/env/ejb/Manufacture" ); ManufactureHome home = (ManufactureHome) PortableRemoteObject.narrow( objref, ManufactureHome.class ); return home.create(currentCellID); } catch (NamingException ne) { throw new EJBException(ne); } catch (java.rmi.RemoteException re) { throw new EJBException(re); } catch (javax.ejb.CreateException ce) { throw new EJBException(ce); } } }

  31. import java.util.Date; import factory.manage_orders.OpenOrderView; import factory.manage_orders.OverdueOrderView; public class OrderView { private int salesDivision; private int orderNumber; private String product; private String status; private Date dateDue; public OrderView(int salesDivision, int orderNumber, String product, String status, Date dateDue ) { this.salesDivision = salesDivision; this.orderNumber = orderNumber; this.product = product; this.status = status; this.dateDue = dateDue; } public OrderView(OpenOrderView view) { this(view.salesDivision, view.orderNumber, view.product, "open", view.dateDue ); } public OrderView(OverdueOrderView view) { this( view.salesDivision, view.orderNumber, view.product, view.status, view.dateDue ); } View.javaclass Returns information from the model

  32. View.java (cont.) public OrderView() {} public int getSalesDivision() { return salesDivision; } public int getOrderNumber() { return orderNumber; } public String getProduct() { return product; } public String getStatus() { return status; } public Date getDateDue() { return dateDue; } }

  33. createrouting.jsp Create a routing for product : Sequence Routing or you can be finished with creating routings for this product.

  34. Code for createrouting.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> <html> <head> <title>Wrox Sample Code - Create a Routing</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p>Create a routing for product <%= modelManager.getCurrentProductID()%>:</p> <form method="post" action="routing_created"> <p>Sequence <input type="text" name="sequence"></p> <p>Routing <textarea name="routing" cols="75" rows="10"></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> <p>or you can be <a href="choices">finished with creating routings for this product</a>.</p> </body> </html>

  35. placeorder.jsp Place an order for a product: Sales division Order number Product Due date

  36. Code for placeorder.jsp <html> <head> <title>Wrox Sample Code - Place an Order</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p>Place an order for a product:</p> <form method="post" action="order_placed" name="PlaceOrder"> <p>Sales division <input type="text" name="sales_div"></p> <p>Order number <input type="text" name="order_num"></p> <p>Product <input type="text" name="prod"></p> <p>Due date <input type="text" name="due_date"></p> <p><input type="submit" name="Submit" value="Submit"> </p> </form> <p>&nbsp;</p> </body> </html>

  37. message.jsp Thank you message Thank you for placing this order. Return to main menu.

  38. Code for message.jsp <html> <head> <title>Wrox Sample Code - Message</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p> <%= request.getAttribute("message")%>. </p> <p><a href="choices">Return to main menu.</a></p> </body> </html>

  39. manageorders.jsp Sales Division Order Number Product Date Due Click to Cancel ">cancel Overdue Order and Open Order Manage Your Orders You are currently viewing . ">Click here to view . Return to main menu

  40. Code for manageorder.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> <%@ page import="java.util.Iterator" %> <%@ page import="OrderView" %> <html> <head> <title>Wrox Sample Code - Manage Orders</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p>Manage Your Orders</p> <p>You are currently viewing <%= request.getAttribute("order_view")%>. <a href="manageorders?ordertype=<%= request.getAttribute("order_alt_url")%>">Click here to view <%= request.getAttribute("order_alt_view") %>.</a></p>

  41. Code for manageorder.jsp (cont.) <table width="87%" border="1"> <tr> <td width="21%">Sales Division</td> <td width="23%">Order Number</td> <td width="19%">Product</td> <td width="16%">Date Due</td> <td width="21%">Click to Cancel</td> </tr> <% String orderView = (String) request.getAttribute("order_view"); Iterator iter = modelManager.getOrders( orderView ); while (iter.hasNext()) { OrderView view = (OrderView) iter.next(); %>

  42. Code for manageorder.jsp (cont.) <tr> <td width="21%"><%=view.getSalesDivision()%></td> <td width="23%"><%=view.getOrderNumber()%></td> <td width="19%"><%=view.getProduct()%></td> <td width="16%"><%=view.getDateDue()%></td> <td width="21%"><a href="cancelorder?salesdivision=<%=view. getSalesDivision()%>&ordernumber=<%=view.getOrderNumber() %>&ordertype=<%=request.getAttribute("order_url")%>">cancel</a></td> </tr> <% }%> </table> <p>&nbsp; <a href="choices">Return to main menu</a> </p> </body> </html>

  43. manufacturechoose.jsp Sales Division Order Number Product Date Due Choose an order to manufacture:

  44. Code for manufacturechoose.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> <%@ page import="java.util.Iterator" %> <%@ page import="OrderView" %> <html> <head> <title>Wrox Sample Code - Select for Manufacture</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p>Choose an order to manufacture:</p> <table width="87%" border="1">

  45. Code for manufacturechoose.jsp(cont.) <tr> <td width="21%">Sales Division</td> <td width="23%">Order Number</td> <td width="19%">Product</td> <td width="16%">Date Due</td> </tr> <% Iterator iter = modelManager.getOrdersToManufacture(); while (iter.hasNext()) { OrderView view = (OrderView) iter.next(); %> <tr> <td width="21%"><%=view.getSalesDivision()%></td> <td width="23%"><a href="order_chosen?salesdivision=<%=view. getSalesDivision()%>&ordernumber=<%=view.getOrderNumber() %>"><%=view.getOrderNumber()%></a></td> <td width="19%"><%=view.getProduct()%></td> <td width="16%"><%=view.getDateDue()%></td> </tr> <% }%> </table></body> </html>

  46. cellid.jsp First time user will asked to log in Login: Enter your current manufacturing cell identification string:

  47. Code for cellid.jsp <html> <head> <title>Wrox Sample Code - Enter Your Cell ID</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p>Login:</p> <form method="post" action="cell_chosen"> <p>Enter your current manufacturing cell identification string: <input type="text" name="cell"> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> <p>&nbsp; </p> </body> </html>

  48. manufactureroute.jsp Here is the next step in the manufacture of this product: Solder the lid on the product. Click here when completed.

  49. Code for manufactureroute.jsp <jsp:useBean id="modelManager" class="ModelManager" scope="session" /> <html> <head> <title>Wrox Sample Code - Routing Step</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <p>Here is the next step in the manufacture of this product:</p> <p><jsp:getProperty name="modelManager" property="nextRouting"/></p> <p><a href="manufactureroute">Click here when completed.</a></p> <p>&nbsp; </p> <p>&nbsp; </p> </body> </html>

  50. ship.jsp Ship the manufactured product: Shipping company: Loading dock:

More Related