Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ofbiz-component name="practice"
   
        xmlnsxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsixsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
        <resource<resource-loader 	name="main" type="component"/>
      <webapp name="practice"
           titletitle="Practice"
           serverserver="default-server"
             base-permission="OFBTOOLS"
           locationlocation="webapp/practice"
           mount-point="/practice"
           appapp-bar-display="false"/>
</ofbiz-component>

...

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsixsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">

           <include<include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
           <description>Practice<description>Practice Component Site Configuration File</description>
           <owner>Copyright<owner>Copyright 2001-2008 The Apache Software Foundation</owner>

           <<!-- Request Mappings -->

       <request-map uri="main">
           <security https="false" auth="false"/>
           <response name="success" type="view" value="main"/>
       </request-map>

           <<!-- end of request mappings -->

           <<!-- View Mappings -->

       <view-map name="main" type="screen" page="component://practice/widget/PracticeScreens.xml#main"/>

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

*Step - 1 :*Now add one more menu item to by name "PersonForm" to your PracticeMenus.xml file.

Step - 2: Create one file in widget by name PracticeForms.xml and create a list form for showing the records from person entity.
(Take reference from ExampleScreens.xml and ExampleForms.xml files).

*Step - 3 :*Create new screen by name personForm and include this list form in it.

...

Now its the time to show practice application in the app bar :

*Step - 1 :*For this just make app-bar-display="true" in ofbiz-component.xml file.

Restart the server then run it again you will find practice application in app bar.

Create UI Labels:

*Step - 1 :*For this create directory by name "config" in your component directory i.e. "practice".

...

{color:#000000which will be : <classpath type="dir" location="config"/> means you have to place the config directory on the classpath to access configuration files.

Step - 2: Now create a file by name PracticeUiLabels.xml and create some of the ui labels for practice applicaton. (take reference from ExampleUiLabels.xml). Here remember one thing whenever you make a change in UiLabels then you have to restart the server for having the changes in effect. At first create only 2 ui labels like

...

Step - 3 : Do an entry in ofbiz-component.xml file for this seca definition to to be loaded. It will be :

Code Block

<entity-resource type="eca" reader-name="main" loader="main" location="entitydef/eecas.xml"/>


 Don't forget to restart the server after doing this entry.

...

Step - 1 :  For extending an entity useyou can do in this manner in the entitydef/entitymodel.xml file of your custom application.

Code Block
<extend-entity entity-name="">
    <field name="" type=""/>
</extend-entity>


      As an example of this you can refer entitymodel.xml file from party component.

This is the simplest form it can be more complex. This will add up one more field to the entity you already have. Now it depends which field you want for your custom needs. Here you can also defined relation of this field with other entities you want. But before doing this you should search extesively may be you will be adding a field for a purpose and there is already a field which will serve the purpose, so be concisous about this. Also go for a extensive study of data model then do this.

For entity engine configuration dont forget to read : Entity Engine Configuration Guide

Preparing Data For Custom Application:

 For preparing data for your practice application following steps can be performed:

Step - 1 : Create new folder in practice by name "data" and create a file in it by name PracticeData.xml.

Step - 2 : Now we are going to create the data for a user for this we have to prepare it in a specific order for a party like :

Code Block

<?xml version="1.0" encoding="UTF-8"?>
<entity-engine-xml>
    <Party partyId="DemoUser" partyTypeId="PERSON"/>
    <Person partyId="DemoUser" firstName="Practice" lastName="Person"/>
    <PartyRole partyId="DemoUser" roleTypeId="VISITOR"/>

    <ContactMech contactMechId="5000" contactMechTypeId="EMAIL_ADDRESS" infoString="practice.person@gmail.com"/>
    <PartyContactMech partyId="DemoUser" contactMechId="5000" fromDate="2001-05-13 00:00:00.000" allowSolicitation="Y"/>
    <PartyContactMechPurpose partyId="DemoUser" contactMechId="5000" contactMechPurposeTypeId="PRIMARY_EMAIL" fromDate="2001-05-13 00:00:00.000"/>
</entity-engine-xml>

The purpose is to create a record for a party who is a person with a role of VISITOR and creating an email address which is a primary email address for that party.

Step - 3:  Now we have to an entry in ofbiz-component.xml file :

Code Block

<entity-resource type="data" reader-name="demo" loader="main" location="data/PracticeData.xml"/>

After doing this entry when you will run the command ant run-install to load demo data then the data from this file will be loaded as demo data and once you start the server you can see this record added for person by going to Person Form in practice application or you can prefer to go to https://localhost:8443/webtools/control/entitymaintImage Added and find each entity and check the records have gone in the database or not.

Conclusion:

If you have followed all the steps and developed practice application from this application then this will really help you in understanding other implementations in OFBiz. These things are basic foundation of working in OFBiz. Now you know that how you can start the development in OFBiz. Don't leave the extra links provided in this tutorial as they will really help you a lot in understanding the things which are there. Parallaly with the development of this application you can watch OFBiz videos which are available at Framework Introduction Videos.

...