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 οnclick="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