update_customer.screen
查找screendefinitions_en_US.xml 由于petsotre的界面使用了一個模板taglib,這個模板將屏幕分成: title 標題 banner 廣告 sidebar 菜單邊 body 正文 mylist 特殊顯示 footer 頁腳 這個思路可以借鑒到我們系統中。 從其中找到update_customer.screen的真正程序名是:
也就是是edit_customer.jsp
打開edit_customer.jsp 發現其form action又是自己定義的, action="customer.do" 也就是說update_customer.screen頁面是提交到customer.do程序的。
再查詢customer.do是什么?
在mappings.xml中查詢到:
com.sun.j2ee.blueprints.petstore.controller.web.actions.CustomerHTMLAction
customer.do實際是com.sun.j2ee.blueprints.petstore.controller.web.actions.CustomerHTMLAction這個servlet 那么打開com.sun.j2ee.blueprints.petstore.controller.web.actions.CustomerHTMLAction:
這個servlet主要是處理update_customer.screen提交form中的參數, ContactInfo info = extractContactInfo(request, "_a"); CreditCard creditCard = extractCreditCard(request); ProfileInfo profileInfo = extractProfileInfo(request); 將這些從前臺用戶那里輸入的新數據打包在一個叫CustomerEvent類中: event = new CustomerEvent(CustomerEvent.UPDATE, info, profileInfo, creditCard);
這個CustomerEvent很重要,是承接前臺和后臺EJB處理的中間樞紐。
從mappings.xml可以查詢到:
com.sun.j2ee.blueprints.petstore.controller.events.CustomerEvent com.sun.j2ee.blueprints.petstore.controller.ejb.actions.CustomerEJBAction
CustomerEvent實際是激活 CustomerEJBAction.
打開CustomerEJBAction,我們發現了updateCustomer(CustomerEvent ce) 這個方法將前臺用戶的新數據set到EJB中。 CustomerEJBAction也并不是直接和entity bean打交道,而是通過ShoppingClientFacadeLocalEJB 這是個Facade模式。
下次我們討論MainServlet 這個MainServlet實際上是petstore MVC的總controller,但是它和具體數據又沒有關系,上面的customer.do實際是通過MainServlet激活的。 |