您的位置:首页 >> 编程开发 >> Java >> JavaBeans >> 正文
RSS
 

Petstore源码追踪记(3)-商业逻辑处理(五)

http://www.rdxx.com 01年11月18日 11:08 互联网 我要投稿

关键词: 商业 , 逻辑 , Stor

            }
        }
        if (currentScreen == null) {
            System.err.println("ScreenFlowManager: Screen not found for " +
selectedURL);
            throw new RuntimeException("Screen not found for " + selectedURL);
        }
        //进行转导动作(forward)
        System.out.println("forward to "+ currentScreen);
        context.getRequestDispatcher("/" + currentScreen).forward(request,
response);

}

我们知道它会转导至customer.screen,从screendefinitions_en_US.xml,可找到对应各画面区块:


<screen name="customer">
  <parameter key="title" value="Customer" direct="true"/>
  <parameter key="banner" value="/banner.jsp" />
  <parameter key="sidebar" value="/sidebar.jsp" />
  <parameter key="body" value="/customer.jsp" />
  <parameter key="mylist" value="/mylist.jsp" />
  <parameter key="footer" value="/footer.jsp" />
</screen>

其实大部份与main.screen都相同,唯一差异部份就是主体区块(body),开启
customer.jsp
瞧它的内容,位置在Petstore_home\src\apps\petstore\src\docroot
,在约50列:


<table cellpadding="5" cellspacing="0" width="100%" border="0">
<tr>
<td colspan="3"><p class="petstore_title">Contact Information</p></td>
</tr>
<tr>
<td class="petstore_form" align="right"><b>First Name</b></td>

<td class="petstore_form" align="left"
colspan="2"><c:out value="${customer.account.contactInfo.givenName}"/></td>
</tr>
以下略...

以上程序代码作用要将使用者名称(First Name)显示出现,它利用JSTL Tags

资料打印出来,可是问题来了,资料是如何得来的?答案就是本文前头所提到的四个隐形角色之一-SignOnNotifier Attribute Listener

SignOnNotifier
请读者回想前头所提,当使用者身分验证成功后,SignOnFilter会将SIGNED_ON_USER对应变量设定真值(true),存入Session

hreq.getSession().setAttribute(SIGNED_ON_USER, new Boolean(true));

此时便会触发SignOnNotifier,请开启:
Petstore_home\src\apps\petstore\src\com\sun\j2ee\blueprints\petstore\controller\web\SignOnNotifier.java
,在约89列:

/**
 * Process an attribute added
 *属性新增后

 */
public void attributeAdded(HttpSessionBindingEvent se) {
   processEvent(se);
}

/**
 * Process the update
 *
属性覆盖后

 */
public void attributeReplaced(HttpSessionBindingEvent se) {
   processEvent(se);
}

private void processEvent(HttpSessionBindingEvent se) {
   HttpSession session = se.getSession();
   String name = se.getName();

   /* check if the value matches the signon attribute
   * if a macth fire off an event to the ejb tier that the user
   * has signed on and load the account for the user

 
 
标签: 商业 , 逻辑 , Stor 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站