OFBiz的探索进阶
主要參照https://cwiki.apache.org/OFBIZ/ofbiz-tutorial-a-beginners-development-guide.html這個教程,實現的過程教程上很詳細,故這里不多說
還參考了下http://www.hotwaxmedia.com/apache-ofbiz-blog/ofbiz/ofbiz-tutorials/ofbiz-tutorial-building-a-simple-product-list-screen這個教程
Part 1
教程上說得很詳細,只說一下需要注意的地方:
-
關于web.xml文件,我們需要去framework/example下搜索example的web.xml,然后按照教程修改下列幾項:
<context-param><param-name>webSiteId</param-name><param-value>PRACTICE</param-value><description>A unique ID used to look up the WebSite entity to get information about catalogs, etc.</description> </context-param> <context-param><param-name>localDispatcherName</param-name><param-value>practice</param-value><description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description> </context-param> <context-param><param-name>mainDecoratorLocation</param-name><param-value>component://practice/widget/CommonScreens.xml</param-value><description>The location of the main-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.</description> </context-param> 效果如圖所示:
Part 2
最初版本
- CommonScreens.xml這個文件同樣也是去framework/exmaple中找,然后加入他所示的代碼。
- 需要注意,如果使用了網站上的代碼,要特別注意person的大小寫,源代碼與網上教程的代碼中,person的大小寫是不同的,這個一定要小心
-
第2步中,我們創建了一個menu,代碼如下
<?xml version="1.0" encoding="UTF-8"?> <menus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-menu.xsd"><menu name="PracticeAppBar" title="PracticeApplication" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml"><menu-item name="main" title="Main"><link target="main"/></menu-item></menu> </menus> 這里的
<menu-item name="main" title="Main"><link target="main"/></menu-item> 對于菜單上的一項,如圖所示
至于那個
| <link target="main"/> |
可以理解為當你選了Main這個菜單項的時候,相當于發出了main這個請求,然后去controller找對應的請求要怎么做就行了
-
第5步中,我們使用了如下的代碼建立一個叫做person的screen
<screen name="person"><section><actions><script location="component://practice/webapp/practice/WEB-INF/actions/Person.groovy"/></actions><widgets><decorator-screen name="CommonPracticeDecorator" location="${parameters.mainDecoratorLocation}"><decorator-section name="body"><platform-specific><html><html-template location="component://practice/webapp/practice/Person.ftl"/></html></platform-specific></decorator-section></decorator-screen></widgets></section></screen> 這里對這段代碼做一下簡單的解析:?
1、the screen decorator is used to decorate our screen with all the application menus, the header and footer that are shared by all the screens;
2、the screen specific content will go in the “body” section of the decorator, that is why we use the “decorator-section” element and add the screen specific content there
3、the path to the form widget definition is expressed in the format?“component://<ofbiz component name>/<relative path to the form definition xml file>”; this format is widely used in ofbiz and it is useful because makes the system independent from the actual location of the ofbiz home folder and also enables the extension mechanism of OFBiz -
由于我們使用了新的請求,所以需要在controller.xml中添加相應的request-map,代碼如下
<?xml version="1.0" encoding="UTF-8"?> <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd"><include location="component://common/webcommon/WEB-INF/common-controller.xml"/><description>Practice Component Site Configuration File</description><owner>Copyright 2001-2009 The Apache Software Foundation</owner><handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/><!-- Request Mappings --><request-map uri="main"><security https="false" auth="false"/><response name="success" type="view" value="main"/></request-map><request-map uri="person"><security https="false" auth="false"/><response name="success" type="view" value="person"/></request-map><!-- end of request mappings --><!-- View Mappings --><view-map name="main" type="screen" page="component://practice/widget/PracticeScreens.xml#main"/><view-map name="person" type="screen" page="component://practice/widget/PracticeScreens.xml#person"/><!-- end of view mappings --> </site-conf> ?
Now moving to create a form for showing the content of Person entity on the screen (Using Form Widget)
controller.xml的改動如下:
| <?xml version="1.0" encoding="UTF-8"?> <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd"><include location="component://common/webcommon/WEB-INF/common-controller.xml"/><description>Practice Component Site Configuration File</description><owner>Copyright 2001-2009 The Apache Software Foundation</owner><handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/><!-- Request Mappings --><request-map uri="main"><security https="false" auth="false"/><response name="success" type="view" value="main"/></request-map><request-map uri="person"><security https="false" auth="false"/><response name="success" type="view" value="person"/></request-map><request-map uri="personForm"><security https="false" auth="false"></security><response name="success" type="view" value="personform"/></request-map><!-- end of request mappings --><!-- View Mappings --><view-map name="main" type="screen" page="component://practice/widget/PracticeScreens.xml#main"/><view-map name="person" type="screen" page="component://practice/widget/PracticeScreens.xml#person"/><view-map name="personform" type="screen" page="component://practice/widget/PracticeScreens.xml#personForm"/><!-- end of view mappings --> </site-conf> |
- 需要注意,這里的request的personForm的F是大寫的,寫成小寫翻頁會出現錯誤
訪問http://localhost:8080/practice/control/personForm,效果如圖所示:
Create main Decorator for decorating this application
在 CommonScreens.xml中加入main-decorator的定義后,我們需要改進一下CommonPracticeDecorator的代碼:
| <!-- CommonParcticeDecorator for use main-decorator--><screen name="CommonPracticeDecorator"><section><widgets><decorator-screen name="main-decorator"><decorator-section name="body"><decorator-section-include name="body"/></decorator-section></decorator-screen></widgets></section></screen> |
然后重新訪問
效果如圖:
突然發現炫了好多....
Now its the time to show practice application in the app bar
貌似沒有發現什么變化...
Create UI Labels
- config文件夾建立在E:\apache-ofbiz-10.04.02\hot-deploy\practice目錄下,就是說與ofbiz-component.xml同一級
-
加入config文件夾后,ofbiz-component.xml的修改如下:
<?xml version="1.0" encoding="UTF-8"?> <ofbiz-component name="practice"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd"><resource-loader name="main" type="component"/><classpath type="dir" location="config"/><webapp name="practice"title="Practice"server="default-server"base-permission="OFBTOOLS"location="webapp/practice"mount-point="/practice"app-bar-display="true"/> </ofbiz-component> ?
PracticeUiLabels.xml這樣寫:
| <?xml version="1.0" encoding="UTF-8"?> <resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><property key="PracticeApplication"><value xml:lang="en">This is first practice</value></property><property key="PracticeCompanyName"><value xml:lang="en">OFBiz: Practice</value></property> </resource> |
至于這里寫了兩個key有什么用,官方的tutorial表述不是很輕,而在http://www.hotwaxmedia.com/apache-ofbiz-blog/ofbiz/ofbiz-tutorials/ofbiz-tutorial-building-a-simple-product-list-screen這篇文章的Internationalization這一部分中有一定的解答,這里的PracticeUiLabels.xml的作用我感覺有點像android中的string.xml,就定義了一個變量名(容許我這么說),然后它對應的值,然后我們不在直接用值,而是用這個變量,這里是間接的思想吧。
Secure Your Application by Authentication
很遺憾,這一步我沒有做出來,因為我找了ExampleMenus.xml這個文件,但我沒有在里面找到所說的login and logout options,以后回頭再看看這里吧
Part3
Writing CRUD Operations
Writing services
需要特別注意的:由于所有的service都需要在在ofbiz啟動時候載入,所以,我們需要在ofbiz-component.xml中加入service的定義
| <?xml version="1.0" encoding="UTF-8"?> <ofbiz-component name="practice"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd"><resource-loader name="main" type="component"/><classpath type="dir" location="config"/><classpath type="dir" location="script"/><service-resource type="model" loader="main" location="servicedef/services.xml"/><webapp name="practice"title="Practice"server="default-server"base-permission="OFBTOOLS"location="webapp/practice"mount-point="/practice"app-bar-display="true"/> </ofbiz-component> |
其中,minilang的定義如下:
Minilang can help developers to reduce the time it takes to implement simple and repetitive tasks. Code does not need to be compiled and can therefore be implemented faster, breaking the typical Java code-compile-test cycle. Minilang gives the advantage of being able to change the code without a restart of the application.?
簡單來說它是ofbiz專用的語言,用來處理CRUD操作,認證操作等操作,效率上比java快,但由于我們的項目是用java的,故這里僅作簡單了解。
Writing CRUD Operations for Party Entity
1、在servicedef目錄下創建services.xml(有個s別少打了!)
2、在services.xml中寫Party的CRUD的操作,代碼如下:
| <?xml version="1.0" encoding="UTF-8"?> <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd"><description>Practice Services</description><vendor>OFBiz</vendor><version>1.0</version><!-- CRUD Operations for Party Entity --><service name="createPracticeParty" default-entity-name="Party" engine="simple"location="component://practice/script/org/ofbiz/practice/PracticeServices.xml" invoke="createPracticeParty" auth="true"><description>Create a Party</description><auto-attributes include="pk" mode="OUT" optional="false"/><auto-attributes include="nonpk" mode="IN" optional="true"/></service><service name="updatePracticeParty" default-entity-name="Party" engine="simple"location="component://practice/script/org/ofbiz/practice/PracticeServices.xml" invoke="updatePracticeParty" auth="true"><description>Update a Party</description><auto-attributes include="pk" mode="IN" optional="false"/><auto-attributes include="nonpk" mode="IN" optional="true"/></service><service name="deletePracticeParty" default-entity-name="Party" engine="simple"location="component://practice/script/org/ofbiz/practice/PracticeServices.xml" invoke="deletePracticeParty" auth="true"><description>Delete a Party</description><auto-attributes include="pk" mode="IN" optional="false"/></service> |
Writing CRUD Operations for Person Entity
按照教程加入代碼,最后訪問http://localhost:8080/practice/control/personForm,效果如圖:
不知道怎么,排版不像教程那樣好看。
嘗試點擊update或者delete,發現什么都不能做,所以我們在controller.xml中加入對應的request-map
| <request-map uri="deletePracticePerson"><security https="false" auth="true"></security><event type="service" invoke="deletePracticePerson"></event><response name="success" type="view" value="personform"></response></request-map><request-map uri="updatePracticePerson"><security https="false" auth="true"></security><event type="service" invoke="updatePracticePerson"></event><response name="success" type="view" value="personform"></response></request-map> |
這樣一來,這兩個鍵就能正常使用了
Writing Events
1、在menu bar上加入Event這個tag
| <menu name="PracticeAppBar" title="PracticeApplication" default-menu-item-name="personList" default-selected-style="selected"extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml"><menu-item name="main" title="Main"><link target="main"/></menu-item><menu-item name="person" title="Person"><link target="person"></link></menu-item><menu-item name="personList" title="Person List"><link target="personForm"></link></menu-item><menu-item name="events" title="Events"><link target="events"/></menu-item></menu> |
效果:
需要注意的是,由于我們還沒有在controller.xml中寫關于events的request-map,所以這時候如果點Events是會報錯的
2、創建一個包含EventMinilang"和"EventJava“的menu
| <menu name="EventMenu" default-menu-item-name="eventMinilang" default-selected-style="selected"type="simple" menu-container-style="button-bar button-style-1" selected-menuitem-context-field-name="headerItem"><menu-item name="eventMinilang" title="Create Person --- Event MiniLang"><link target="createPracticePersonEventM"/></menu-item><menu-item name="eventJava" title="Create Person --- Event Java"><link target="createPracticePersonEventJ"/></menu-item> </menu> |
其實EventMenu在界面上知識對應這一塊
3、不知道什么意思
4、在PracticeSreens.xml創建不同event對應的界面
| <screen name="CreatePracticePersonEventM"><section><actions><set field="headerItem" value="eventMinilang"/><set field="titleProperty" value="PageTitleSimpleEventForms"/></actions><widgets><decorator-screen name="CommonPracticeDecorator" location="${parameters.mainDecoratorLocation}"><decorator-section name="body"><include-menu location="component://practice/widget/PracticeMenus.xml" name="EventMenu"/><label text="New Person --- Simple Event" style="h1"/><include-form name="CreatePersonSimpleForm" location="component://practice/widget/PracticeForms.xml"/></decorator-section></decorator-screen> </widgets></section></screen><screen name="CreatePracticePersonEventJ"><section><actions><set field="headerItem" value="eventJava"/><set field="titleProperty" value="PageTitleJavaEventForms"/></actions><widgets><decorator-screen name="CommonPracticeDecorator" location="${parameters.mainDecoratorLocation}"><decorator-section name="body"><include-menu location="component://practice/widget/PracticeMenus.xml" name="EventMenu"/><label text="New Person --- Java Event" style="h1"/><include-form name="CreatePersonJavaForm" location="component://practice/widget/PracticeForms.xml"/></decorator-section></decorator-screen></widgets></section></screen> |
5、在PracticeForm.xml中加入如下代碼:
| <form name="CreatePersonSimpleForm" type="single" target="createPracticePersonSimpleEvent"><auto-fields-service service-name="createPracticePerson"/><field name="submitButton" title="${uiLabelMap.CommonCreate}" widget-style="smallSubmit"><submit button-type="button"/></field></form><form name="CreatePersonJavaForm" type="single" target="createPracticePersonJavaEvent"><auto-fields-service service-name="createPracticePerson"/><field name="submitButton" title="${uiLabelMap.CommonCreate}" widget-style="smallSubmit"><submit button-type="button"/></field></form> |
現在我們就在controller.xml加入相應的request-map
menu bar上events對應的request-map
| <request-map uri="events"><security https="false" auth="true"/><response name="success" type="view" value="CreatePracticePersonEventM"/> </request-map> |
Event Menu中兩項對應的request-map
| <request-map uri="CreatePracticePersonEventM"><security https="false" auth="true"/><response name="success" type="view" value="CreatePracticePersonEventM"/> </request-map> <request-map uri="CreatePracticePersonEventJ"><security https="false" auth="true"/><response name="success" type="view" value="CreatePracticePersonEventJ"/> </request-map> |
PracticeForm中對應的request-map
| <request-map uri="createPracticePersonSimpleEvent"><security https="true" auth="true"/><event type="simple" path="org/ofbiz/practice/PracticeEvents.xml" invoke="createPracticePersonSimpleEvent"/><response name="success" type="view" value="CreatePracticePersonEventM"/><response name="error" type="view" value="CreatePracticePersonEventM"/></request-map><request-map uri="createPracticePersonJavaEvent"><security https="true" auth="true"/><event type="java" path="org.ofbiz.practice.PracticeEvents" invoke="createPracticePersonJavaEvent"/><response name="success" type="view" value="CreatePracticePersonEventJ"/><response name="error" type="view" value="CreatePracticePersonEventJ"/></request-map> |
?
添加相應的view-map
| <view-map name="CreatePracticePersonEventM" type="screen" page="component://practice/widget/PracticeScreens.xml#CreatePracticePersonEventM"/> <view-map name="CreatePracticePersonEventJ" type="screen" page="component://practice/widget/PracticeScreens.xml#CreatePracticePersonEventJ"/> |
需要注意:網站上給的源碼中,在view-map這里有一個Events的view-map,這個是沒有用到的,而且在PracticeScreen.xml中并沒有Events這個Sreen,所以這里完全是沒用的,故不要加進去
效果:
Simple Minilang Event
略
Java Event
需要做的有三件事:
1、在hot-deploy/practice目錄下建立一個/src/org/ofbiz/practice的目錄
2、在這個目錄中建立一個PracticeEvents.java文件,內容如下:
| package org.ofbiz.practice; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericValue; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.GenericServiceException; public class PracticeEvents {public static final String module = PracticeEvents.class.getName();public static String createPracticePersonJavaEvent(HttpServletRequest request, HttpServletResponse response) {LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");String salutation = (String) request.getParameter("salutation");String firstName = (String) request.getParameter("firstName");String middleName=(String) request.getParameter("middleName");String lastName=(String) request.getParameter("lastName");String suffix=(String) request.getParameter("suffix");// Map createPersonContext = new HashMap(); // createPersonContext.put("firstName", firstName); // createPersonContext.put("middleName", middleName); // createPersonContext.put("lastName", lastName); // createPersonContext.put("suffix", suffix);Map createPersonCtx = UtilMisc.toMap("salutation", salutation, "firstName", firstName, "middleName", middleName, "lastName", lastName, "suffix", suffix, "userLogin", userLogin);try {Map person = dispatcher.runSync("createPracticePerson", createPersonCtx);} catch (GenericServiceException e) {Debug.logError(e.toString(), module);return "error";}return "success";} } |
自己的理解是每一個Event對應一個方法,這里的createPracticePersonJavaEvent對應到controller.xml的下面語句
| <request-map uri="createPracticePersonJavaEvent"><security https="true" auth="true"/><event type="java" path="org.ofbiz.practice.PracticeEvents" invoke="createPracticePersonJavaEvent"/><response name="success" type="view" value="CreatePracticePersonEventJ"/><response name="error" type="view" value="CreatePracticePersonEventJ"/></request-map> |
3、在ofbiz-component.xml中加入一句:
4、在practice目錄下建立一個build.xml文件
這個文件是用來給ant編譯我們的java的event的。但是我沒有安裝ant。所以,需要到apache的官網上下一個ant,我下的是apache-ant-1.8.4。
安裝方法:
1)將安裝包解壓到某個盤,我解壓到E盤
2)在用戶變量中添加ANT_HOME
需要注意:是用戶變量而不是系統變量,系統變量我加了沒成功
3)修改PATH
4)命令行運行ant看是否成功
如果出現上圖就說明安裝ant配置好了
接下來我們就在命令行進入到practice所在目錄,輸入ant
5、最后重啟ofbiz,java event就完成了。
Part 4
ECA(Event Condition Action)
1、在menu bar上添加ECA這個選項
在PracticeMenu.xml中加入這樣一個選項
| <menu-item name="eca" title="ECA"><link target="eca"/></menu-item> |
在controller.xml中加入相對應的request-map
| <request-map uri="eca"><security https="false" auth="true"></security> </request-map> |
2、在PracticeMenu.xml加入ECA的menu
| <menu name="EcaMenu" default-menu-item-name="seca" default-selected-style="selected"type="simple" menu-container-style="button-bar button-style-2" selected-menuitem-context-field-name="headerItem"><menu-item name="seca" title="Create Person --- SECA"><link target="seca"/></menu-item><menu-item name="eeca" title="Create Person --- EECA"><link target="eeca"/></menu-item> </menu> |
并且在controller.xml中加入對應的request-map
| <request-map uri="eca"><security https="false" auth="true"></security></request-map><request-map uri="seca"><security https="false" auth="true"></security></request-map><request-map uri="eeca"><security https="false" auth="true"></security></request-map> |
SECA
1、在service.xml中加入createPartyRoleVisitor這個服務
| <service name="createPartyRoleVisitor" engine="simple" location="org/hotwax/practice/PracticeServices.xml" invoke="createPartyRoleVisitor" default-entity-name="PartyRole" auth="true"><description>Create a new PartyRole when a party is created</description><attribute name="partyId" mode="IN" type="String" optional="false"/> </service> |
2、在servicedef目錄下創建secas.xml文件,寫入如下的內容:
| <?xml version="1.0" encoding="UTF-8"?> <service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/service-eca.xsd"><eca service="createPracticePerson" event="commit"><condition field-name="partyId" operator="is-not-empty"/><action service="createPartyRoleVisitor" mode="sync"/></eca> </service-eca> |
進進從代碼上看,應該是如果在createPracticePerson進行commit的時候,如果partyId不為空,就會自動調用createPartyRoleVisitor服務
3、修改ofbiz-component.xml,加入下面語句
| <service-resource type="eca" loader="main" location="servicedef/secas.xml"/> |
4、完善controller中的跳轉
| <request-map uri="eca"><security https="false" auth="true"></security><response name="success" type="view" value="seca"></response> </request-map> <request-map uri="seca"><security https="false" auth="true"></security><response name="success" type="view" value="seca"></response> </request-map> <request-map uri="eeca"><security https="false" auth="true"></security><response name="success" type="view" value="eeca"></response> </request-map> |
?
| <view-map name="seca" type="screen" page="component://practice/widget/PracticeScreens.xml#seca"></view-map> <view-map name="eeca" type="screen" page="component://practice/widget/PracticeScreens.xml#eeca"></view-map> |
5、在PracticeScreen.xml中創建對應的界面
| <screen name="seca"><section><actions><set field="headerItem" value="seca"/><set field="titleProperty" value="PageTitleSecaForm"/></actions><widgets><decorator-screen name="CommonPracticeDecorator" location="${parameters.mainDecoratorLocation}"><decorator-section name="body"><include-menu location="component://practice/widget/PracticeMenus.xml" name="EcaMenu"/><label text="New Person --- SECA" style="h1"/><include-form name="CreatePerson" location="component://practice/widget/PracticeForms.xml"/></decorator-section></decorator-screen></widgets></section></screen><screen name="eeca"><section><actions><set field="headerItem" value="eeca"/><set field="titleProperty" value="PageTitleEecaForm"/></actions><widgets><decorator-screen name="CommonPracticeDecorator" location="${parameters.mainDecoratorLocation}"><decorator-section name="body"><include-menu location="component://practice/widget/PracticeMenus.xml" name="EcaMenu"/><label text="New Person --- EECA" style="h1"/><include-form name="CreatePerson" location="component://practice/widget/PracticeForms.xml"/></decorator-section></decorator-screen></widgets></section></screen> |
6、重啟ofbiz,訪問localhost:8080/practice/control/eca進行測試
這是效果,但由于我不知道在哪里查看教程上說的PartyRole entity,所以也不清楚有了這個seca會帶來什么變化
EECA
1、createPartyRoleCustomer的代碼如下:
| <service name="createPartyRoleCustomer" engine="simple" location="org/hotwax/practice/PracticeServices.xml" invoke="createPartyRoleCustomer" default-entity-name="PartyRole" auth="true"><description>Create a new PartyRole when a party is created</description><attribute name="partyId" mode="IN" type="String" optional="false"/></service> |
2、創建一個entitiydef目錄,在其中寫一個eeca.xml文件,代碼如下
| <?xml version="1.0" encoding="UTF-8"?> <entity-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/entity-eca.xsd"><!-- To create party role whenever a party is created --><eca entity="Party" operation="create" event="return"><condition field-name="partyId" operator="is-not-empty"/><action service="createPartyRoleCustomer" mode="sync"/></eca></entity-eca> |
3、在ofbiz-component.xml中添加進隊eecas.xml的定義
4、重啟,測試
問題和SECA一樣,由于我不知道在哪里查看PartyRole,所以無法得知EECA會帶來什么變化,直觀上來看,當創建了一個Party示例時候,就會同步地創建一個PartyRoleCustomer實體
Group Service
暫略
Interface
暫略
Part 5
Creating Custom Entity
暫略
Extending an Existing OOTB Entity
暫略
Preparing Data For Custom Application
我們可以自己定義一些數據,然后載入到ofbiz中進行測試
按照教程,建立data目錄與PracticeData.xml,寫入
| <?xml version="1.0" encoding="UTF-8"?> <entity-engine-xml><Party partyId="MyDemoUser" partyTypeId="PERSON"/><Person partyId="MyDemoUser" firstName="ZTK_Practice" lastName="ZTK_Person"/><PartyRole partyId="MyDemoUser" roleTypeId="VISITOR"/><ContactMech contactMechId="5000" contactMechTypeId="EMAIL_ADDRESS" infoString="mypractice.person@gmail.com"/><PartyContactMech partyId="MyDemoUser" contactMechId="5000" fromDate="2001-05-13 00:00:00.000" allowSolicitation="Y"/><PartyContactMechPurpose partyId="MyDemoUser" contactMechId="5000" contactMechPurposeTypeId="PRIMARY_EMAIL" fromDate="2001-05-13 00:00:00.000"/><WebSite webSiteId="MYPRACTICE" siteName="Practice Application" visualThemeSetId="BACKOFFICE"/> </entity-engine-xml> |
保存,然后用命令行進入到ofbiz的主目錄,運行ant run-install,就像剛開始按照那樣,這里大概需要2到3分鐘。
加載完數據后,運行startofbiz.bat,訪問?https://localhost:8443/webtools/control/entitymaint
在Person這個表中搜索,可以看到
在Party這個表中搜索,可以看到
在ContactMech這個表中搜索,可以看到
說明我們成功地向數據庫中添加進了自己定義的數據!
轉載于:https://www.cnblogs.com/ztk3939339/archive/2012/08/08/2627686.html
總結
以上是生活随笔為你收集整理的OFBiz的探索进阶的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery实战--定宽
- 下一篇: [Buzz Today]2012.08.