文章用途
本文内容代码为简单的单表CRUD代码模板替换成功后的Demo代码!
替换说明
按下列注释指定的关键字替换,
然后放到每块代码上对应对应的注释内提到的xml文件中,
重启项目即可使用!
<!-- app-name[模块名称]: learn; entityTitle[表描述]: 学习; entityModelName[表名]: Learn; pkId[表主键名]: learnId; type[类型]: learnTypeId; name[名称]: learnName; date[日期时间]: learnDate; Screen/Menu/Form[文件前缀]: Learn; webapp-site[app站点]: learn -->
<!-- component://learn/entitydef/entitymodel.xml #表结构定义 --> <entity entity-name="Learn" package-name="org.ofbiz.learnxpp"> <description>学习xpp</description> <field name="learnId" type="id-ne"><description>ID</description></field> <field name="learnTypeId" type="id-ne"><description>类型ID</description></field> <field name="learnName" type="name"><description>名称</description></field> <field name="learnDate" type="date-time"><description>日期时间</description></field> <field name="description" type="description"><description>描述</description></field> <field name="enable" type="indicator"><description>是否可用(Y/N)</description></field> <prim-key field="learnId"/> </entity>
<!-- component://learn/config/LearnUiLabels.xml #国际化资源配置xpp --> <property key="FindLearn"> <value xml:lang="en">FindLearnxpp</value> <value xml:lang="zh">管理学习</value> </property> <property key="EditLearn"> <value xml:lang="en">EditLearn</value> <value xml:lang="zh">编辑学习</value> </property> <property key="ViewLearn"> <value xml:lang="en">ViewLearn</value> <value xml:lang="zh">查看学习</value> </property> <property key="learnId"> <value xml:lang="en">ID</value> <value xml:lang="zh">编号</value> </property> <property key="learnTypeId"> <value xml:lang="en">Type</value> <value xml:lang="zh">类型</value> </property> <property key="learnName"> <value xml:lang="en">Name</value> <value xml:lang="zh">名称</value> </property> <property key="learnDate"> <value xml:lang="en">DateTime</value> <value xml:lang="zh">日期时间</value> </property> <property key="description"> <value xml:lang="en">description</value> <value xml:lang="zh">描述</value> </property> <property key="enable"> <value xml:lang="en">enable</value> <value xml:lang="zh">是否可用</value> </property> <property key="From"> <value xml:lang="en">From</value> <value xml:lang="zh">从</value> </property> <property key="To"> <value xml:lang="en">To</value> <value xml:lang="zh">到</value> </property> <property key="enableYes"> <value xml:lang="en">Yes</value> <value xml:lang="zh">是</value> </property> <property key="enableNo"> <value xml:lang="en">No</value> <value xml:lang="zh">否</value> </property> <property key="confirmDeleteMsg"> <value xml:lang="en">Confirm Delete xpp ?</value> <value xml:lang="zh">确认删除 ?</value> </property>
<!-- component://learn/widget/LearnMenus.xml #xpp菜单配置 --> <menu-item name="FindLearn" title="${uiLabelMap.FindLearn}"> <link target="FindLearn" /> </menu-item>
<!-- component://learn/webapp/learn/WEB-INF/controller.xml #xpp请求配置 --> <!-- Learn xpp Request --> <request-map uri="FindLearn"> <security auth="true" https="true"/> <response name="success" type="view" value="FindLearn" /> </request-map> <request-map uri="EditLearn"> <security auth="true" https="true"/> <response name="success" type="view" value="EditLearn" /> </request-map> <request-map uri="ViewLearn"> <security auth="true" https="true"/> <response name="success" type="view" value="ViewLearn" /> </request-map> <request-map uri="createLearn"> <security auth="true" https="true"/> <event type="service" invoke="createLearn" /> <response name="success" type="request-redirect-noparam" value="FindLearn" /> <response name="error" type="view" value="EditLearn"/> </request-map> <request-map uri="updateLearn"> <security auth="true" https="true"/> <event type="service" invoke="updateLearn" /> <response name="success" type="request-redirect-noparam" value="FindLearn"/> <response name="error" type="view" value="EditLearn"/> </request-map> <request-map uri="deleteLearn"> <security auth="true" https="true"/> <event type="service" invoke="deleteLearn" /> <response name="success" type="request-redirect-noparam" value="FindLearn"/> </request-map>
<!-- Learn View xpp --> <view-map name="FindLearn" type="screen" page="component://learn/widget/LearnScreens.xml#FindLearn" /> <view-map name="ViewLearn" type="screen" page="component://learn/widget/LearnScreens.xml#ViewLearn" /> <view-map name="EditLearn" type="screen" page="component://learn/widget/LearnScreens.xml#EditLearn" />
<!-- component://learn/widget/LearnScreens.xml #xpp显示页面配置 --> <screen name="FindLearn"> <section> <actions> <!-- html.head.title 显示描述xpp --> <set field="titleProperty" value="FindLearn"/> <!-- 菜单xpp高亮 --> <set field="headerItem" value="FindLearn"/> </actions> <widgets> <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> <decorator-section name="body"> <include-form name="FindLearn" location="component://learn/widget/LearnForms.xml" /> <link target="EditLearn" text="${uiLabelMap.CommonCreate}" style="buttontext"/> <include-form name="ListLearn" location="component://learn/widget/LearnForms.xml" /> </decorator-section> </decorator-screen> </widgets> </section> </screen> <screen name="EditLearn"> <section> <actions> <!-- html.head.xpp 显示描述 --> <set field="titleProperty" value="FindLearn"/> <!-- 菜单高亮xpp --> <set field="headerItem" value="FindLearn"/> <!-- xpp业务数据 --> <set field="learnId" from-field="parameters.learnId"/> <entity-one entity-name="Learn" value-field="entity" /> </actions> <widgets> <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> <decorator-section name="body"> <include-form name="EditLearn" location="component://learn/widget/LearnForms.xml" /> </decorator-section> </decorator-screen> </widgets> </section> </screen> <screen name="ViewLearn"> <section> <actions> <!-- html.head.title 显示描述xpp --> <set field="titleProperty" value="FindLearn"/> <!-- xpp菜单高亮 --> <set field="headerItem" value="FindLearn"/> <!-- 业务数据xpp --> <set field="learnId" from-field="parameters.learnId"/> <entity-one entity-name="Learn" value-field="entity" /> </actions> <widgets> <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> <decorator-section name="body"> <include-form name="ViewLearn" location="component://learn/widget/LearnForms.xml" /> </decorator-section> </decorator-screen> </widgets> </section> </screen>
<!-- component://learn/widget/LearnForms.xml #xpp显示页面内表单配置 --> <!-- Forms xpp Learn --> <form name="FindLearn" type="single" target="FindLearn" default-map-name="search" default-entity-name="Learn" header-row-style="header-row" default-table-style="basic-table"> <field name="learnId" title="${uiLabelMap.learnId}"><text-find hide-options="true" /></field> <field name="learnName" title="${uiLabelMap.learnName}" position="2"><text-find hide-options="true" /></field> <field name="enable" title="${uiLabelMap.enable}"> <drop-down allow-empty="true"> <option key="Y" description="${uiLabelMap.enableYes}"/> <option key="N" description="${uiLabelMap.enableNo}"/> </drop-down> </field> <field name="learnDate_fld0_value" title="${uiLabelMap.learnDate}(${uiLabelMap.From})" widget-style="dateISO" position="2" > <date-time type="date" /> </field> <field name="learnDate_fld0_op"><hidden value="greaterThanEqualTo"/></field> <field name="learnTypeId" title="${uiLabelMap.learnTypeId}"> <drop-down allow-empty="true"> <entity-options description="${description}" entity-name="Enumeration" key-field-name="enumId"> <entity-constraint name="enumTypeId" value="_NA_"/> <entity-learn-by field-name="sequenceId"/> </entity-options> </drop-down> </field> <field name="learnDate_fld1_value" title="(${uiLabelMap.To})" widget-style="dateISO" position="2"> <date-time type="date" /> </field> <field name="learnDate_fld1_op"><hidden value="lessThanEqualTo"/></field> <field name="searchButton" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit"><submit/></field> </form> <form name="ListLearn" list-name="listIt" type="list" paginate-target="FindLearn" separate-columns="true" odd-row-style="alternate-row" default-table-style="basic-table"> <actions> <set field="parameters.noConditionFind" value="Y"/> <set field="entityNameSearch" value="Learn"/> <set field="learnBySearch" value="+learnId"/> <service service-name="performFind" result-map="result" result-map-list="listIt"> <field-map field-name="inputFields" from-field="parameters"/> <field-map field-name="entityName" from-field="entityNameSearch"/> <field-map field-name="learnBy" from-field="learnBySearch"/> <field-map field-name="viewIndex" from-field="viewIndex"/> <field-map field-name="viewSize" from-field="viewSize"/> </service> </actions> <field name="learnId" title="${uiLabelMap.learnId}" widget-style="buttontext" sort-field="true"> <hyperlink target="ViewLearn" description="${learnId}"> <parameter param-name="learnId"/> </hyperlink> </field> <field name="learnName" title="${uiLabelMap.learnName}" sort-field="true"><display/></field> <field name="learnDate" title="${uiLabelMap.learnDate}" sort-field="true"><display type="date-time"/></field> <field name="learnTypeId" title="${uiLabelMap.learnTypeId}" sort-field="true"> <display-entity entity-name="Enumeration" description="${description}[${learnTypeId}]" key-field-name="enumId"/> </field> <field use-when=""Y".equals(enable)" name="enable" title="${uiLabelMap.enable}" sort-field="true"> <display description="${uiLabelMap.enableYes}[Y]"/> </field> <field use-when="!"Y".equals(enable)" name="enable" title="${uiLabelMap.enable}" sort-field="true"> <display description="${uiLabelMap.enableNo}[N]"/> </field> <field name="EditLearn" title="${uiLabelMap.CommonEdit}" widget-style="buttontext"> <hyperlink target="EditLearn" description="${uiLabelMap.CommonEdit}"> <parameter param-name="learnId"/> </hyperlink> </field> <field name="deleteLearn" title="${uiLabelMap.CommonDelete}" widget-style="buttontext"> <hyperlink target="deleteLearn" confirmation-message="${uiLabelMap.confirmDeleteMsg}" target-type="intra-app" description="${uiLabelMap.CommonDelete}"> <parameter param-name="learnId"/> </hyperlink> </field> </form> <form name="EditLearn" type="single" target="updateLearn" default-map-name="entity" header-row-style="header-row" default-table-style="basic-table"> <alt-target use-when="entity==null" target="createLearn" /> <field name="learnId"> <hidden /> </field> <field name="learnTypeId" title="${uiLabelMap.learnTypeId}"> <drop-down allow-empty="true"> <entity-options description="${description}" entity-name="Enumeration" key-field-name="enumId"> <entity-constraint name="enumTypeId" value="_NA_"/> <entity-learn-by field-name="sequenceId"/> </entity-options> </drop-down> </field> <field name="learnName" title="${uiLabelMap.learnName}"><text/></field> <field name="description" title="${uiLabelMap.description}"><textarea/></field> <field name="learnDate" title="${uiLabelMap.learnDate}"><date-time type="date" default-value="${nowTimestamp}"/></field> <field name="enable" title="${uiLabelMap.enable}" widget-style="required"> <drop-down allow-empty="false" no-current-selected-key="Y"> <option key="Y" description="${uiLabelMap.enableYes}"/> <option key="N" description="${uiLabelMap.enableNo}"/> </drop-down> </field> <field use-when="entity==null" name="submitButton" title="${uiLabelMap.CommonCreate}" widget-style="smallSubmit"><submit button-type="button"/></field> <field use-when="entity!=null" name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit"><submit button-type="button"/></field> <field name="GobackLearn" title=" " widget-style="buttontext"> <hyperlink target="FindLearn" description="${uiLabelMap.CommonGoBack}"/> </field> </form> <form name="ViewLearn" type="single" default-map-name="entity" header-row-style="header-row" default-table-style="basic-table"> <actions> <set field="enable" from-field="entity.enable"/> </actions> <field name="learnId" title="${uiLabelMap.learnId}"><display/></field> <field name="learnName" title="${uiLabelMap.learnName}"><display/></field> <field name="description"><display/></field> <field name="learnDate" title="${uiLabelMap.learnDate}"><display type="date-time"/></field> <field name="learnTypeId" title="${uiLabelMap.learnTypeId}"> <display-entity entity-name="Enumeration" description="${description}" key-field-name="enumId"/> </field> <field use-when=""Y".equals(enable)" name="enable" title="${uiLabelMap.enable}"> <display description="${uiLabelMap.enableYes}"/> </field> <field use-when="!"Y".equals(enable)" name="enable" title="${uiLabelMap.enable}"> <display description="${uiLabelMap.enableNo}"/> </field> <field name="GobackLearn" title=" " widget-style="buttontext"> <hyperlink target="FindLearn" description="${uiLabelMap.CommonGoBack}"/> </field> </form>
<!-- component://learn/servicedef/services.xml #xpp服务配置 --> <!-- entity-auto Learn Services xpp --> <service name="createLearn" default-entity-name="Learn" engine="entity-auto" invoke="create" auth="true"> <description>Create a Learnxpp</description> <auto-attributes include="pk" mode="INOUT" optional="true"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> </service> <service name="updateLearn" default-entity-name="Learn" engine="entity-auto" invoke="update" auth="true"> <description>Update a Learnxpp</description> <auto-attributes include="pk" mode="IN" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> </service> <service name="deleteLearn" default-entity-name="Learn" engine="entity-auto" invoke="delete" auth="true"> <description>Delete a Learn</description> <auto-attributes include="pk" mode="IN" optional="false"/> </service>
到此, 一个简单的CRUD 代码以及涉及到的模块文件路径都列出来了!
希望能对广大新人有帮助!
后续
附送 Minilang 版实现代码
相关推荐
小谈ofbiz学习,发展历史,学习体验和心得,以及ofbiz与其他框架的不同之处
最新版OFBiz,apache-ofbiz-16.11.05,apache-ofbiz-16.11.05
Ofbiz 官网上的OFBiz Tutorial - A Beginners Development Guide中的案例practice,其中内容有些是老版本的,与新版本(13版)并不兼容,尤其是Ajax部分已经有较大差异。同时有一部分操作和源代码没有在教程中说明...
Apache OFBiz E-Business Solutions.pdf 一千多页,OFBiz 9.04
Apache-Ofbiz-16-全量数据库873张表sql文件
OFBiz教程-初学者开发指南,适合初学者,解决初学者学习ofbiz入门问题
OFBiz API 文档,英文html版。使用官方资源中的ant命令自动生成,无任何修改。有兴趣的朋友可以自己生成,ant命令是:docs-all,该命令生成帮助文档时会获取操作系统语言设置,要生成英文文档请先将操作系统语言改为...
OFBiz实践,百货购,挺好的东西,分享给大伙,欢迎下载
不用解压ofbiz-entry-zh-cn.zip 直接把zip修改为doc 即可。 ofbiz-entry-zh-cn.doc 博文链接:https://jiasudu.iteye.com/blog/157892
OFBiz-manual-zh.docOFBiz-manual-zh.docOFBiz-manual-zh.docOFBiz-manual-zh.docOFBiz-manual-zh.doc
ofbiz权限非常介绍,ofbiz进阶之权限介绍!
apache-ofbiz-16.11.02.zip,ofbiz菜鸟笔记,Apache+OFBiz+开发初学者指南.chm
NULL 博文链接:https://enica.iteye.com/blog/2026693
NULL 博文链接:https://enica.iteye.com/blog/2026632
NULL 博文链接:https://enica.iteye.com/blog/2028263
Ofbiz-minilang标签示例
Ofbiz-minilang标签示例,主要是解释minilang包含的一些标签的用法