20180126--ofbiz增删改查之修成正果篇

1.  LearnUiLabels.xml

<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="learnDate">
    	<value xml:lang="en">Date</value>	
    	<value xml:lang="zh">日期</value>	
    </property>
    <property key="learnName">
    	<value xml:lang="en">Name</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>
2.   entitymodel.xml

<entity entity-name="LearnType" package-name="org.ofbiz.Learnxpp" title="Learn Type Entity">
        <field name="learnTypeId" type="id"><description>primary sequenced ID</description></field>
        <field name="description" type="description"></field>
        <prim-key field="learnTypeId"/>
    </entity> 
    <entity entity-name="Learn" package-name="org.ofbiz.learnxpp">  
    
    <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"/> 
    <relation type="one" fk-name="ODEM_OD_TYPE_ID" rel-entity-name="LearnType">
            <key-map field-name="learnTypeId"/>
        </relation> 
</entity>
3. controller.xml
<request-map uri="main">
		<security auth="true" https="true" />
		<response name="success" type="view" value="FindLearn" />
	</request-map>
	<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="main" />
		<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="main" />
		<response name="error" type="view" value="EditLearn" />
	</request-map>
	<request-map uri="deleteLearn">
		<security auth="true" https="false" />
		<event type="service" invoke="deleteLearn" />
		<response name="success" type="request-redirect-noparam"
			value="FindLearn" />
	</request-map>

	<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" />
4.  LearnScreens.xml
<screen name="FindLearn">  
    <section>  
        <actions>  
            <set field="titleProperty" value="FindLearn"/>  
            <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>   
            <set field="titleProperty" value="FindLearn"/>  
            <set field="headerItem" value="FindLearn"/>  
            <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>   
            <set field="titleProperty" value="FindLearn"/>  
            <set field="headerItem" value="FindLearn"/>  
            <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>
5.  LearnForms.xml

	        <!-- 查找表单-->
<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="LearnType" key-field-name="learnTypeId" />  
             <entity-order-by field-name="description"/> 
        </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="orderBy" 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="description" title="${uiLabelMap.description}"><display/></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>
6.  services.xml

<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>








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值