文章用途
本文内容代码为简单的单表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(Open For Business Project)是一个开源的企业级业务应用框架,旨在提供一套全面的...在学习过程中,参考示例组件,遵循编码规范和最佳实践,将对你的OFBiz开发之路大有裨益。
本篇文章将探讨的是OFBiz的开发入门,特别是关于CmsBackEnd如何实现CRUD操作,即创建(Create)、读取(Retrieve)、更新(Update)和删除/Delete。 首先,理解OFBiz的基本架构至关重要。OFBiz采用Service Engine、Entity...
创建新记录涉及定义实体(Entity)和实体扩展(EntityExt),在OFBiz中,实体模型是XML文件,定义了数据表的结构。然后,使用服务(Service)来处理插入操作,服务可以通过XML定义,包含事务控制、输入输出参数等。...
本教程将带你逐步了解如何入门OFBiz,以及如何在OFBiz环境中进行基本的CRUD(创建、读取、更新、删除)操作。 首先,你需要从官方下载页面获取OFBiz的最新版本,例如12.04.02,并将其解压缩到本地文件夹,如F:\...
本文档的编写旨在帮助OFBIZ新手快速理解并开始组件开发,通过实践来深入学习OFBIZ的技术栈,使开发者能够在实践中掌握技能,实现“在水中学会游泳”。 ### 2. OFBIZ组件 OFBIZ中的组件是其核心模块,每个组件都是...
ofbiz初学者的一些文档资料,包括 1、A1-OFBiz功能介绍-xpp2、A 2、Apache+OFBiz+开发...4、A3-OFBiz创建模块-基本CRUD图文教程 5、B1-OFBiz开发指南-Ob4.0-EN[Apache-OFBiz-Development-The-Beginners-Tutorial]
Apache OFBiz(Open For Business)是一个开源的电子商务平台,被广泛用于构建企业级的商务应用程序。它提供了丰富的电子商务功能,例如订单处理、库存管理、供应商和合作伙伴管理等。OFBiz具备灵活的架构,可以通过...
- 在OFBiz中,实体(Entity)是数据存储的核心概念,类似于数据库中的表。 - 实体定义在`.xml`文件中,通过实体引擎(Entity Engine)进行操作,提供增删改查的API。 4. **OFBiz的CRUD操作** - 创建(Create):...
在Ofbiz中,实体引擎是核心组件之一,它负责处理数据模型,提供数据访问和管理功能。本篇文章将深入探讨Ofbiz实体引擎的设计理念、主要功能以及实际应用。 ### 一、Ofbiz实体引擎概述 Ofbiz实体引擎基于Java语言,...
**OpenTaps与Apache OfBiz架构详解** OpenTaps(Open Source Total Appliance for Professional Services)是一款基于Apache OfBiz的企业级开源商务套件,旨在提供全面的企业应用解决方案,包括CRM(客户关系管理)...
- **MVC模式**:OFBIZ的Web应用框架基于Model-View-Controller模式,这使得业务逻辑、用户界面和数据访问得以分离,增强了代码的可维护性和可扩展性。 - **设计模式**:在实体引擎中,OFBIZ采用了多种设计模式,...
创建一个新的数据表"StudyCustomer",包含"customerId"(Integer类型)、"customerName"(String类型)和"customerNote"(String类型),实现基本的CRUD操作,步骤如下: 1. 创建XML定义文件: - 在"entitymodel_...
4. 数据访问:Groovy可以方便地与OFBiz的数据层交互,执行CRUD操作。 "OFBiz开发者装备系列:0005"可能是一个关于OFBiz开发的学习资料系列,其中的"Groovy中文教程.pdf"可能是该系列的一部分,提供了详细的Groovy...