解剖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 金家寶 阅读(307) 评论(0)  编辑  收藏 所属分类: J2EE概念理论性文摘


只有注册用户登录后才能发表评论。


网站导航: