解剖Petstore用戶資料修改流程


          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激活的。

          posted on 2007-03-09 02:04 金家寶 閱讀(349) 評論(0)  編輯  收藏 所屬分類: J2EE概念理論性文摘

          主站蜘蛛池模板: 青浦区| 鄂托克旗| 永平县| 图木舒克市| 天台县| 通渭县| 孟村| 安图县| 华亭县| 镇原县| 永和县| 佛教| 论坛| 康乐县| 临武县| 阳山县| 云南省| 枞阳县| 阿尔山市| 沙雅县| 金沙县| 高青县| 呼图壁县| 高陵县| 丹阳市| 清涧县| 二连浩特市| 广南县| 莫力| 长宁区| 得荣县| 塔城市| 五大连池市| 九寨沟县| 鸡泽县| 定襄县| 游戏| 宜兰县| 宁武县| 山东| 乌兰县|