随笔-39  评论-33  文章-0  trackbacks-0

newxy 的 Delphi 开发风格二(主细表)

胡立新

 

newxy 新坐标开发主细表结构的页面极其简单,如同 Delphi 。下面讨论如何利用 newxy 新坐标的标签创建主细表结构。

设主表 industry( 行业 ) ,相关 formBean 名 formIndustry ,保存在会话中,细表 enterprise( 企业 ) ,相关的 formBean 名 formEnterprise ,可保存在会话中,也可保存在 pageContext 中。

注意, newxy 的通用动态 formBean 含一集合属性 _coll ,保存记录集。

一、 例图, 在线演示

图上所示为点击了“制造业”后显示的相关企业。

二、 策略

1、   在 jsp 页面上得到两个 formBean ,分表是主表 formBean ,设名为 formIndustry ,细表 formBean ,设名为 formEnterprise ;

2、   主表 formBean(formIndustry) 可以在本 jsp 页上产生,也可直接从会话中得到,细表 formBean 要在本 jsp 页上形成。从主表 formBean(formIndustry) 上得到细表的外键 code (行业代码),再由这外键作为查询条件查得细表 formBean(formEnterprise) ;

3、   将主细表信息显示出来。

三、 实现 ( 黑体为 newxy 的标签 )

1、   查询得主表 formBean(formIndustry) :

<nbean:formBean name="formIndustry" sql="select * from table_"  />

2、   显示主表;

        <nlogic:iterate id="rec" name="formIndustry" property="_coll" leftover="true">
        <nhtml:TR onclick="edit(actIndustry);">

          <td style="cursor:hand" align="center">1</td>
          <td style="cursor:hand"><nbean:write name="rec" property="industry"/></td>
        </nhtml:TR>

        </nlogic:iterate>

3、   得到主表当前关键字值(行业代码),存入 pageContext :

    <bean:define id=" _code " name="formIndustry" property=" code "/>

4、   根据行业代码查询得到细表 formBean(formEnterprise) :

<nbean:formBean name="formEnterprise" sql="select * from enterprise where industry_code=''$ {_code}"/>

5、   显示细表:

        <nlogic:iterate id="rec" name="formEnterprise" property="_coll" leftover="true">
        <nhtml:TR>

          <td align="center">
            $ {index+1}
          </td>
          <td style="cursor:hand"><nbean:write name="rec" property="principal"/></td>
          <td style="cursor:hand"><nbean:write name="rec" property="name"/></td>
        </nhtml:TR>

        </nlogic:iterate>

四、 相关连接

1、   newxy 新坐标技术网站 http://www.newxy.net

2、   在线演示: newxy 的 delphi 开发风格二(主细表) http://demo.newxy.net/delphi/sample2.jsp

3、   在线演示: newxy 的 delphi 开发风格一 http://demo.newxy.net/delphi/sample1.jsp

4、   DAO 类 + 通用持久类 + 通用动态 formBean 类,实现数据增、删、改、查 http://www.newxy.net/zh_cn/introduction/application/index.jsp?item=daoDtoAndForm

5、   DynaFormBean 类的特点 http://www.newxy.net/zh_cn/introduction/docs/doc.jsp#anchor9.3

6、   newxy 的 Delphi 开发风格二(主细表) JSP 源码 http://demo.newxy.net/delphi/sample2_jsp.jsp

posted on 2007-03-25 00:28 newxy新坐标 阅读(1600) 评论(0)  编辑  收藏

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


网站导航: