如何基于ofbiz在页面中显示一张数据库表(利昂原创)

(备注:要看懂该文章必须具备OFBIZ的基础知识。)
 
关键代码1:在widget的screen中,action部分用<entity-condition 标签指定实体名和实体列表名
关键代码2:在widget的screen中,widgets部分用<include-form 标签指定被引用表单的位置和表单名
<screen name="guestbook">
        <section>
            <actions>
<!-- find HelloPerson by condition.  since there is no conditions, all values of HelloPerson are returned in allGuests -->
             <entity-condition entity-name="HelloPerson" list-name="allGuests"><order-by field-name="helloPersonId"/></entity-condition>
    <!--窗口中调用的表单用到的实体数据在该处指出!!如果该句设置得不对表单中将不显示数据!!!-->
            </actions>
          <widgets>
                <decorator-screen name="CommonDecorator">
                    <decorator-section name="body">
                        <label>我们的客人和他们说的话</label>  <!-- a label/header -->
                         <!-- use this form directly, instead of going through a Freemarker template again -->
                         <include-form name="GuestbookList" location="component://hello3/webapp/hello3/guestbook/GuestbookForms.xml"/>
                        
                          </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
 
关键代码3:在表单文件内的对应(上面的<include-form 标签指出的表单名)的表单代码处,<form 标签的type要设成list,list-name要和widget中窗口中的action部分的列表名一致。
<form name="GuestbookList" type="list" list-name="allGuests">
<!-- 该处的列表名和widget的窗口action中指定的列表名要对应!this form just lists all the values of allGuests -->
        <auto-fields-entity entity-name="HelloPerson" default-field-type="display"/>
<!-- 自动显示指定实体的所有域automatically display all fields from HelloPerson -->  
</form>
 
        总体思路就是:form根据实体定义创建表头,action里的entity condition根据条件从数据库中取出数据显示于表中,这就完成了在页面上显示数据库表的过程。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值