OFBiz经典入门教程加速度编写

OFBiz入门教程

 

OFBiz的ant命令 新建一个scm模块。

 

 

1 如何定义model 

在scm/entitydef/entitymodel.xml中

新建供应商model,如下:

 

 <entity entity-name="HSupplier" package-name="org.ofo.ooo" title="HSupplier  Entity">

<field name="baseId" type="id-ne"><description>序列号</description></field>

<field name="uniqueName" type="id-ne" >

     <description></description>

 </field>

<field name="companyCode" type="id-ne">

<description>公司编号</description>

</field>

<field name="subCompanyCode" type="id-ne">

<description>单位编号</description>

</field>

<field name="shopCode" type="id-ne">

<description>门店编号</description>

</field>

<field name="departmentCode" type="id-ne">

<description>部门编号</description>

</field>

<field name="supplierCode" type="id-ne">

<description>供应商编号</description>

</field>

<field name="supplierName" type="name">

<description>名称</description>

</field>

<field name="address" type="name">

<description>地址</description>

</field>

<field name="zipcode" type="id">

<description>邮编</description>

</field>

 

<field name="contact" type="name">

<description>联系人</description>

</field>

<field name="contactPhone" type="name">

<description>联系人电话</description>

</field>

<field name="managerPerson" type="name">

<description>负责人</description>

</field>

<field name="managerPersonCode" type="name">

<description>负责人编号</description>

</field>

 

<field name="bankAccount" type="name">

<description>银行帐号</description>

</field>

<field name="fax" type="id">

<description>传真</description>

</field>

<field name="email" type="id">

<description>邮箱</description>

</field>

<field name="qq" type="id">

<description>QQ</description>

</field>

 

<field name="description" type="description">

<description>描述</description>

</field>

 

 

<prim-key field="baseId"/>

     </entity> 

 


2 如何定义service 

 

在/scm/servicedef/services.xml中

创建2个service服务定义 新建供应商,修改供应商的服务

 

    <service name="createHSupplier" default-entity-name="HSupplier" engine="entity-auto" invoke="create" auth="true">

        <description>Create a HSupplier</description>

        <auto-attributes include="pk" mode="OUT" optional="false"/>

        <auto-attributes include="nonpk" mode="IN" optional="true"/>

    </service>

    <service name="updateHSupplier" default-entity-name="HSupplier" engine="entity-auto" invoke="update" auth="true">

        <description>Update a HSupplier</description>

        <auto-attributes include="pk" mode="IN" optional="false"/>

        <auto-attributes include="nonpk" mode="IN" optional="true"/>

    </service>

3 如何定义control 

 

在scm/webapp/scm/WEB-INF/controller.xml中

创建request-map请求,如下: 查询供应商 、查看供应商、 编辑供应商、新建供应商、修改供应商、删除供应商。

对应的view-map请求 如下:查询供应商、查看供应商、编辑供应商。

 

 

<request-map uri="FindHSupplier"><security auth="true"/><response name="success" type="view" value="FindHSupplier"/></request-map>

    <request-map uri="ViewHSupplier"><security auth="true"/><response name="success" type="view" value="ViewHSupplier"/></request-map>

    <request-map uri="EditHSupplier"><security auth="true"/><response name="success" type="view" value="EditHSupplier"/></request-map>

    <request-map uri="createHSupplier">

        <event type="service" invoke="createHSupplier"/>

        <response name="success" type="request-redirect-noparam" value="FindHSupplier"></response>

        <response name="error" type="view" value="FindHSupplier"/>

    </request-map>

    <request-map uri="updateHSupplier">

        <event type="service" invoke="updateHSupplier"/>

                <response name="success" type="request-redirect-noparam" value="FindHSupplier"></response>

    </request-map>

    <request-map uri="deleteHSupplierMultiValue">

        <event type="service" invoke="deleteMultiValue"/>

                <response name="success" type="request-redirect-noparam" value="FindHSupplier"></response>

    </request-map>

 

 

 

 

 <view-map name="FindHSupplier" type="screen" page="component://scm/widget/ScmScreens.xml#FindHSupplier"/>

    <view-map name="ViewHSupplier" type="screen" page="component://scm/widget/ScmScreens.xml#ViewHSupplier"/>

    <view-map name="EditHSupplier" type="screen" page="component://scm/widget/ScmScreens.xml#EditHSupplier"/> 

4 如何定义screen 

 

/scm/widget/ScmScreens.xml中

 

 

 

 

      <screenname="EditHSupplier">

        <section>

            <actions>

                <!-- 菜单高亮显示 -->

                <setfield="headerItem"value="EditHSupplier"/>

                <!-- 头部标题 -->

                <setfield="headerTitle"value="EditHSupplier"/>

                <!-- 业务数据 -->

 

            </actions>

            <widgets>

               <decorator-screenname="ScmCommonDecorator"location="${parameters.mainDecoratorLocation}">

                    <decorator-section name="body">

                        <include-formname="EditHSupplier"location="component://scm/widget/ScmForms.xml"/>

 

                    </decorator-section>

                </decorator-screen>

            </widgets>

        </section>

    </screen>

 

    <!-- 查询页面 -->

    <screenname="FindHSupplier">

        <section>

            <actions>

                <!-- 菜单高亮显示 -->

                <setfield="headerItem"value="FindHSupplier"/>

                <!-- 头部标题 -->

                <setfield="headerTitle"value="Supplier"/>

                <!-- 业务数据 -->

 

                <!-- 操作按钮事件 -->

 

 

 

            </actions>

            <widgets>

                <decorator-screenname="FindScreenDecorator"location="component://common/widget/CommonScreens.xml">

                    <decorator-section name="search-options">

                        <include-formname="FindHSupplier"location="component://scm/widget/ScmForms.xml"/>

                    </decorator-section>

                    <decorator-section name="search-results">

                        <include-formname="ListHSupplier"location="component://scm/widget/ScmForms.xml"/>

                    </decorator-section>

                </decorator-screen>

            </widgets>

        </section>

    </screen>

 

 

     <!-- 查看详细信息 带选项卡 -->

    <screenname="ViewHSupplier">

        <section>

            <actions>

                <!-- 头部标题 -->

                <setfield="headerTitle"value="ViewHSupplier"/>

                <!-- 操作按钮及事件 -->

                <!-- 业务数据 -->

 

            </actions>

            <widgets>

                <decorator-screenname="ScmCommonDecorator"location="${parameters.mainDecoratorLocation}">

                    <decorator-section name="body">

                        <include-formname="ViewHSupplier"location="component://scm/widget/ScmForms.xml"/>

 

                    </decorator-section>

                </decorator-screen>

            </widgets>

        </section>

 

    </screen>

5 ftl form的写法和注意事项

创建 编辑供应商的form(新增,修改)、查询供应商的form、列表的form

 

 

<form name="EditHSupplier" type="single"   target="updateHSupplier" default-map-name="entity" >

        <alt-target use-when="entity==null" target="createHSupplier"/>

 

        <field name="baseId" ><hidden/></field>

 

 

<field name="supplierCode" title="供应商编号">

<text/>

</field>

<field name="supplierName" title="名称"  position="2">

<text/>

</field>

<field name="address" title="地址">

<text/>

</field>

<field name="zipcode" title="邮编">

<text/>

</field>

 

<field name="contact" title="联系人">

<text/>

</field>

<field name="contactPhone" title="联系人电话" widget-style="required validate-mobile-phone">

<text/>

</field>

<field name="managerPerson" title="负责人">

<text/>

</field>

<field name="managerPersonCode" title="负责人编号" >

<text/>

</field>

 

<field name="bankAccount" title="银行帐号">

<text/>

</field>

<field name="fax" title="传真" >

<text/>

</field>

<field name="email" title="邮箱" >

<text/>

</field>

<field name="qq" title="QQ" >

<text/>

</field>

 <field name="description" title="备注描述">

<textarea/>

</field>

     </form>

 

     <form name="FindHSupplier" type="single" target="FindHSupplier"  default-map-name="entity" default-entity-name="HSupplier"  >

 

 

<field name="supplierCode" title="供应商编号">

<text-find hide-options="true"/>

</field>

<field name="supplierName" title="名称" position="2">

<text-find hide-options="true"/>

</field>

<field name="address" title="地址">

<text-find hide-options="true"/>

</field>

<field name="zipcode" title="邮编" position="2">

<text-find hide-options="true"/>

</field>

 

<field name="contact" title="联系人">

<text-find hide-options="true"/>

</field>

<field name="contactPhone" title="联系人电话" position="2">

<text-find hide-options="true"/>

</field>

<field name="managerPerson" title="负责人">

<text-find hide-options="true"/>

</field>

<field name="managerPersonCode" title="负责人编号" position="2">

<text-find hide-options="true"/>

</field>

 

 

     </form>

    <form name="ListHSupplier" type="list" list-name="listIt" paginate-target="FindHSupplier" default-entity-name="HSupplier" separate-columns="true" odd-row-style="alternate-row" header-row-style="header-row-2"

        default-table-style="basic-table hover-bar">

<actions>

            <setfield="parameters.noConditionFind"value="Y"/>

            <serviceservice-name="performFind"result-map="result"result-map-list="listIt">

                <field-mapfield-name="inputFields"from-field="parameters"/>

                <field-mapfield-name="entityName"value="HSupplier"/>

                <field-map field-name="orderBy" value="baseId"/>

                <field-mapfield-name="viewIndex"from-field="viewIndex"/>

                <field-map field-name="viewSize" from-field="viewSize"/>

            </service>

 

        </actions>

<field name="baseId" id-name="checkall" title="${uiLabelMap.CommonEmptyHeader}" event="onClick" action="setCheckBox();controlButton('baseId');" widget-area-style="width15">

            <check all-checked="false">

                <option key="${baseId}" description=" " />

            </check>

        </field>

 

<field name="companyCode" title="公司编号">

<display/>

</field>

<field name="subCompanyCode" title="单位编号" >

 <display/>

</field>

   <field name="shopCode" title="门店编号" >

 <display/>

   </field>

<field name="departmentCode" title="部门编号">

 <display/>

</field>

<field name="supplierCode" title="供应商编号">

 <display/>

</field>

<field name="supplierName" title="名称">

 <display/>

</field>

<field name="address" title="地址">

 <display/>

</field>

<field name="zipcode" title="邮编">

 <display/>

</field>

 

<field name="contact" title="联系人">

 <display/>

</field>

<field name="contactPhone" title="联系人电话">

 <display/>

</field>

<field name="managerPerson" title="负责人">

 <display/>

</field>

<field name="managerPersonCode" title="负责人编号">

 <display/>

</field>

 

    </form>

 

你可能感兴趣的:(ofbiz)