Access to add and change pages is restricted. See:

Skip to end of metadata
Go to start of metadata

This tutorial document is targeted at OFBiz beginners. It covers the fundamentals of the OFBiz application development process. The goal of this tutorial is to acquaint a developer with best practices, coding conventions. the control flow and things that the developer needs to know in order to modify OFBiz. This exercise acts as the "Helloworld" for OFBiz similar to the first Helloworld application used when the "C" programming language was introduced by Kernighan and Richie.


This tutorial is intended to be used with the latest version of Apache OFBiz.

For any questions or concerns, please use OFBiz User Mailing List. Details about the mailing lists are available here.

Source Code!

Download Apache OFBiz™
OFBiz Source Repository and Access

The source code of the Practice Application demonstrated in this tutorial can be downloaded from here.

Framework Introduction Videos
OFBiz YouTube Channel or Vimeo can be accessed for the same.

Creating Practice Application (Hello World...)


This tutorial is divided into 6 Parts:

Part 1:  In this part, you will learn how to create and load your own custom component and add a first screen that shows “This is practice application”

Part 2: Going ahead, you will create some advanced GUI patterns, interact with existing database tables and will learn how to secure your web application.

Part 3: Here you learn how to interact with database entities. You will write services for performing CRUD operations (Create, Retrieve, Update, Delete) and form field validation events.

Part 4: In Part 4, you will learn how to call automatic triggers (services) based on conditions that your define.  Calling multiple
services as a group and sharing common parameters of services using the concept of interfaces will be discussed.

Part 5: In this part of the tutorial you will create your custom entity, extend an existing OFBiz entity and prepare the XML data for your application.

Part 6: At the final step you will use Axis for communication between the client and server side applications. After completing this application, you will be an OFBiz developer. (smile)

Do's and Don'ts

  1. For any additional queries and concerns you can refer to the Example component. You will always find the code in the example component reflects the latest version of OFBiz. Refer to it whenever you want to see some sample code for the development of this application. This will help you in future development activities as well.
    When each new feature is added, it is added in the Example component as a reference.
  2. Before starting the development of this application you must read the :
    1. OFBiz Contributors Best Practices ,  
    2. Coding Conventions and
    3. Best Practices Guide
  3. Don't copy any files from other components, as the revision number for the file is also copied. Always create a new file and, if required, copy and paste the contents of the original file. Also be careful to remove any unused code as well.
  4. For searching for any documents the best place to start is : OFBiz Documentation Index.
  5. Right from the beginning, reading the console log must be a habit to make troubleshooting easy. It also gives an understanding of the system's internal processing steps.

Part 1

Create a Component Definition File

  1. Create the sub-directory (folder) in hot-deploy/ and name it "practice" (hot-deploy/practice). The directory name should match the name of the component.
    Note : Remember that all development for this component should be done in this folder only. 
  2. Create the ofbiz-component.xml file on path hot-deploy/practice and place the following contents in it. You can check the corresponding file in any other OOTB OFBiz component to see how it is used in that component.

Explanation of ofbiz-component.xml

The ofbiz-component.xml file is responsible for letting OFBiz know the location of the component's resources. It also adds this location to the classpath. 

The name attribute in the <resource-loader> tag can be any string. Here we are setting it as "main". The type  attribute tells OFBiz that we will be loading a component.



The <webapp> tag,has 7 attributes. :


 Their meanings are shown in the following table


namethe name of our web applicationtrue
titlethe title of the application which will be shown in the top navigationtrue
serverthe server to usetrue
base-permissionthe permissions required to use this component. This example requires that the user should have the OFBTOOLS permission Since the 'admin' user has this permission we do not have to create any new users in order to test this componenttrue
locationthe default base directory for the servertrue
mount-point the URL used to access this resource. in this case it would be localhost:8080/practicetrue
app-bar-displaytrue if the component should show up in the main application tabs that are part of the common OFBiz decoratortrue

Creating the web application configuration

The application that we are creating will follow the J2EE webapp standards.

  1. Create a "webapp" directory in the practice component (hot-deploy/practice/webapp).
    This directory contains all the webapp related files for the component we are creating.
  2. Since "practice" is the name of the webapp which you are going to develop, create a hot-deploy/practice/webapp/practice folder. A component can consist of multiple webapps. E.g. the "marketing" component has two webapps "marketing" and "sfa".
  3. Create the hot-deploy/practice/webapp/practice/WEB-INF directory.
    An OFBiz web application requires two configuration files, a controller.xml and a web.xml. The controller.xml tells OFBiz what to do with various requests from visitors: what actions to take and what pages to render. web.xml tells OFBiz what resources (database and business logic access) are available for this web application and how to handle web-related issues, such as welcome pages, redirects, and error pages.
  4. Create a file named "web.xml"(web.xml follows j2ee webapp specs). Contents of this file can be copied from any of the existing component e.g. /framework/example component. The Important values to change are the <display-name>, the localDispatcherName, the mainDecoratorLocation and the webSiteId.

    1. For now just put websiteId as "PRACTICE". This will be explaned later in this tutorial.
    2. For now put the value: "component://practice/widget/CommonScreens.xml" in for the mainDecoratorLocation. You will see why in a while. This location is used in pointing to the main decorator location in screens like

      This increases the Independence from changes in many places when we need to change the main decorator location. We will just need to change the location in one spot and it will work for all the screens where it has been used. Another advantage of doing this in screens is resuability of existing screens which we can be used in multiple components where the same pattern is used to show the mainDecoratorLocation. Remember this when you add decorators in your screens.

    3. Create a file named "controller.xml" (used by ofbiz webapp controller)  This file will be small and simple at first but will grow as we add functionality later on. For now insert the following code:

      Creating the User Interface

  1. Move up one level and create a new directory named 'error'(hot-deploy/practice/webapp/practice/error).
    1. Create a file error.jsp inside the "error" directory. Contents of this file can be copied from any of the existing component e.g. example component.
      The location of your error page will be specified in the beginning of your controller.xml file like <errorpage>/error/error.jsp</errorpage> . You will need to make or copy over a /webapp/practice/error/error.jsp page to show an error message to the user.
  2. Create a sub-directory inside your component directory "practice" named "widget"(hot-deploy/practice/widget). This directory will contain your forms, menus, and screens which will be created for the UI.
  3. Create a file inside the directory "widget" named "PracticeScreens.xml". Contents of this file can be copied from any existing component  e.g. example component.
    After this, you will be able to create screens views so an important reading at this point is the Best Practices Guide.

Review the application

Now that we have the basic elements in place, let's review the basic flow no matter how large or complex your component gets. First, a request will be made by a browser to see a specific resource.

Take for example the request: "localhost:8080/practice/control/main"

    1. When OFBiz sees this request it will look at the /practice section first. This is because in our ofbiz-component.xml file, we said our webapp's mount point would be /practice. Now OFBiz knows that our practice component will handle the rest of the request.
    2. OFBiz will then look at our controller.xml file. Inside our controller.xml file we have specified request-maps and view-maps. If it finds a request-map with the name 'main', it will use the associated view-map, as follows. The request-map can either specify a view, or as we will see later, an event or a service. If it specifies a view, it will look further down in the controller.xml file and see if there is a view-map with the name specified by the value tag in the request-map.
    3. For now we will keep it simple and assume that all the views go to a type=screen. If this is the case then the page tag will specify a path to a screen definition file as well as a screen name to display after the "#" sign.

Run the "Practice" Applicaction

  1. Now its the time to run you first practice application!
    Start the server by typing the following at the command line : java -Xmx256M -jar ofbiz.jar (the -Xmx256M command just ensures that the program has enough memory) Then, hit the url http://localhost:8080/practice/control/main in your browser.  Your browser should show "This is first practice" as seen below.
    Output Screen :
  2. Create a file in the webapp directory "practice" named index.jsp (Contents of this file can be copied from the "example" component). This file is responsible for redirecting the response to control/main if you give a url such as  http://localhost:8080/practice/. If you give a url such as http://localhost:8080/practice/unknown/request it will be redirected to the redirectPath specified in web.xml. In that case, ContextFilter will filter the request and use the redirect path to redirect the request.

Part 2

Doing Some Advancements To User Interface

  1. Now it is time to create a decorator for the screens in this application. Create a file named CommonScreens.xml in the "widget" directory. This file will contain the common screens which will be used throughout the entire application. A common screen may have a header and footer included so any other screens that use it as a decorator will also have those items. For this you can take reference from the CommonScreens.xml file in the "example" component.
    CommonScreens.xml file code will be:

    Refer to the "CommonScreens.xml" file in the "Example" component to see usage of main-decorator.  Two important references at this moment are Understanding the OFBiz Widget Toolkit and "The Decorator" section in FAQ.
    Add a reference in web.xml to the CommonScreens.xml

  2. Create a menu for this application by creating a file named PracticeMenus.xml in "widget" directory of you component. For this, reference the ExampleMenus.xml file of "example" component.

    Include this menu file in your CommonPracticeDecorator as follows:

  3. Create the sub-directory "actions" inside the WEB-INF directory.
    In this directory we will create the scripting files. Scripting files are used to prepare data on fly. These files will be groovy files. Earlier we were using bsh(beanshell) files. These scripts will be used to fetch the data from database on the fly for the UI.
    Reference : Tips & Tricks while working with Groovy & While working in groovy always be conscious about the imported classes and packages. Import only those which have been used in your file. For putting log messages use methods from "Debug" class. Create a file by name Person.groovy in the "actions" directory to fetch all the records from the entity "Person". At this moment this is really going to be very little code (a single line) like

    The above statement will fetch all the records from the Person entity and will put them in context by the name persons. Now this list will be iterated in the ftl file to show the records.
    At this place an important reading is available at : Which variables are available in screen context?

  4. Now in webapp "practice" create one ftl file by name "Person.ftl" which will be used to show the data fetched by groovy file.
    Reference :
    At this moment you need only to iterate the list of persons. The only code that is needed to do that is:

  5. Now create a new screen entry named "person" in PracticeScreens.xml file and also create a new menu item in PracticeMenus.xml file.
    PracticeScreens.xml new screen entry will be:

  6. Now change the controller.xml file so it points to the new screen, as we did earlier.
    Now again run the application and observe the results by giving http://localhost:8080/practice/control/person .


    If the output screen does not contain the menu as shown below, you will most likely need to change auth="true" to auth="false" in your controller.xml for the menu to come up.

    Output Screen :

Now moving to create a form for showing the content of Person entity on the screen (Using Form Widget)

  1. Now add one more menu item named "PersonForm" to your PracticeMenus.xml file.
  2. Create one file in widget named PracticeForms.xml and create a list form for showing the records from the person entity.
    (Take reference from ExampleScreens.xml and ExampleForms.xml files).

  3. Create new screen named personForm and include this list form in it.

  4. Add this screen to controller.xml.
    Now run the application again and observe the difference.
    So far you have worked on controller requests mappings, Screen widget, form widget, Decorator, Menus, groovy and ftl.

Create main Decorator for decorating this application

  1. Create screen named "main-decorator" in CommonScreens.xml file.(Take reference from CommonScreens.xml file of Example component.)

  2. Now include this decorator in CommonPracticeDecorator screen which you are already having (see above Part 2 - Point 1: "Doing Some Advancements To User Interface")
    Now run it again and see the difference.

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

  • 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

  1. For this create directory by name "config" in your component directory i.e. "practice".
    Note: -Here remember to create an entry for the config directory in your ofbiz-component.xml file.
    which will be:

    That means you have to place the config directory on the classpath to access configuration files.

  2. Now create a file by name PracticeUiLabels.xml and create some of the ui labels for practice application. (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 as:

  3. Include this UI Label resource in your main decorator screen which you created earlier and use these one or two UI labels which you are having now.
  4. Use those 2 UI labels at appropriate places.
    Note: Always search first for any existing UI label in OFBiz and if you don't find it there then only create the new one.
    Now run the application and see the output screen as bellow from:
    Output Screen:

Secure Your Application by Authentication

  1. Take reference from ExampleMenus.xml file for having login and logout options in your menu.
    Targets for these options will be available from "component://common/webcommon/WEB-INF/common-controller.xml", which we have to include in our controller.xml.
    or you can do these entries in your controller.xml file under

    These requests are needed to add in your controller only when you have not included any of the other component controller which consist of these requests. So if you have already included common-controller.xml file then you don't need to explicitly do these entries in your controller.    
    and the same view we have in place can be used for which we have entry in common-controller.xml file we can also have our own:

  2. Make changes in requests in controller.xml file make auth="true" means now these requests needs authentication.
    This is first security level which you have implemented. you request should look like :

    Now run your application and observe the difference. you can login by user name : admin and pwd: ofbizHere we should understand why we had given the permission "OFBTOOLS" in base-permission in ofbiz-component.xml file. To understand this please read following carefully and perform steps as mentioned:
    Confirm that user 'admin' has the 'OFBTOOLS' permission.

    1. Login into partymanager to confirm that the user admin has the required permission
    2. Once your logged in search for the user by typing 'admin' in the User Login field and then clicking the Lookup Party button.
    3.    This does a wild char*  search and you should see multiple users returned.Click the 'Details' button for the admin user.
      Note : Important point to note here is that the person 'Mr. THE PRIVILEGED ADMINISTRATOR' has a partyId admin has multiple login Ids as listed in the
      User Name(s) form.
    4. We interested in the admin user login so click on the 'Security Groups' button and confirm that the use 'admin' is part of the 'FULLADMIN' group. The Groups that the user belongs to is shown in the bottom list form Drill down on the FULLADMIN.
    5. Click on the Permissions tab. This tab shows all the permissions for the FULLADMIN security group. Navigate between the permissions till you find the OFBTOOLS permissions.
      'OFBTOOLS_VIEW Permission to access the Stock OFBiz Manager Applications.' This confirms that the userlogin 'admin' has the permission 'OFBTOOLS'
    6. Take a moment  to review the entity model as it relates to users and permissions. The arrow represents the many side of the relationship.An really important reading at this moment is at : OFBiz Security

Part 3

Writing CRUD Operations

Create, Update and Delete operations for an entity will be done by services which we will be writing in minilang. At first approach we will write our own services for performing these operations for making a better understanding with it. Onwards we will be doing this by calling already implemented services. For doing so we will take the entities from Party model which are:
A person is a party so for the creation of a person record, first a party record needs to be created with partyTypeId="PERSON". So there can be two ways to do that:

  1. Create service for the creation of a party with party type "PERSON".
  2. Create a party first in the service which will be creating person.

Writing Services

  1. Create directory by name "servicedef" in component directory "practice". This directory will contain all the service definition files e.g. services.xml, secas.xml.
    Note : *
    If it is a service which is written in Java then it will be placed in "src" directory and if it is a service which is written in minilang then it will be placed in script directory. e.g. for java applications/party/src/org/ofbiz/party/party/ and for minilang applications/party/script/org/ofbiz/party/party/PartyInvitationServices.xml. Respective class path and file path will be mentioned in the service definition.
  2. In controller you have to create an entry for the request for the execution of a service and set the response like.

  3. Now all the services which you have written needs to be loaded when server starts so you need to do an entry for service definition in ofbiz-component.xml file which will be like:

    So whenever you make any change in any service definition then you must restart the server to have changes in effect.

Writing CRUD Operations for Party Entity

First we will be writing services for Party then while writing services for creating Person we will be calling the service for party.

  1. Create a file by name "services.xml" in servicedef directory.
  2. Define services for CRUD operations for Party entity. Name of services will be createPracticeParty, updatePracticeParty, deletePracticeParty and specify the correct location to the file where these services will be implemented like /framework/example/script/org/ofbiz/example/example/ExampleServices.xml.
  3. Create directory structure and PracticeServices.xml file in your component directory for giving the implementation of these services. (For implementation take reference from services.xml and ExampleServices.xml files of Example component)


    • Do not use the <override> tag as it is introduced later in the tutorial.
      From this place if you want to run these services then you can run them by webtools--> Run Service. By this place you can test your services.
    • At this place you must read This feature has been added against the traditional approach of writing CRUD operations for an entity.

    This new feature enables you to just define the services by mentioning the operation you want to perform.Basically just set the engine attribute to "entity-auto" and the invoke attribute to "create", "update", or "delete".
    like you can take a look in the following code from services.xml of example component:  

    engine="entity-auto" invoke="create" play the role for creating the records for the default-entity "Example."
    Here for practice you may go by following further steps those steps will help you in understanding the concept then onwards you can practice the pattern given above  in your code as its the best practice for these kind of simple operations in OFBiz.

Writing CRUD Operations for Person Entity

- Here for the creation of record for person entity we will need to have the partyId for that so we will first call the service createPracticeParty then after getting the partyId we will create the record for person.
- Here we will be adding one add form in the bottom of the list form which we have for the person entity. This form will be calling the services for creating a record for person.

  1. Create the add form for the creation of person and add this in the same screen for person form.

  2. Write CRUD operations for person entity.this is a code for createPracticePerson in services.xml

    similar for Update and Delete 
    # Now convert the List form with editable field (Ref. ListExampleItems from ExampleForms.xml) and add Update and delete option with it and also in the same screen there is add form also. As shown bellow:

    # Create controller entries for these services which are going to be called by this form.
    Now run the application and see the output screen as bellow:
    Output Screen:

Writing Events

Events can be written in Java and minilang both. Now the next development which you are going to do will be writing these events.
Events are used for the validation and conversion using Simple Map Processor. The Simple Map Processor Mini-Language performs two primary tasks: validation and conversion. It does this in a context of moving values from one Map to another. The input map will commonly contain Strings, but can contain other object types like Integer, Long, Float, Double, java.sql.Date, Time, and Timestamp.
Before moving any further an important link to go through is : Mini-Language Guide (Version 2 - Deprecated), Old link( For making an understanding with it implementation will be done by performing following steps:

  1. For this create another tab in your practice application menu bar for this by Name "Events".
  2. Now create another menu with two menu item in PracticeMenus.xml file by name "EventMenu". This menu will be having 2 menu Item one will be by name "EventMinilang" and  another by name "EventJava". One will be used to show the form which we will be calling an event which will be in minilang and other will be used to call java event.
  3. Simply show form on the request of both which will be for creating a new person. Both the forms will be different for calling different events as target in them.

  4. Show labels in screens above the form like "New Person - Simple Event"  and  "New Person - Java Event" so that it will be easy to identify the purpose of that form.
  5. Now set event in the target of the forms and create request mappings in controller for the event.
    Here important thing to note is in case of simple event controller entry will be like :

    Here the path is the path of the file where the event is written. it will be practice/script/org/hotwax/practice.
    and for java event controller entry will be like:

    Here the path is the classpath in which this event is defined. 
    The file name will be and will be created at  practice/src/org/hotwax/practice.

Simple Minilang Event

  1. Now in the script/org/hotwax/practice/ create one file by name PracticeEvents.xml.
  2. Write the event in PracticeEvents.xml file by name createPracticePersonSimpleEvent.(For reference you can go through the event "createUser" from UserEvents.xml from party component)
    The event which you will be writing should be the simple one as you just have to process 5 fields coming from the form which are salutation, firstName, middleName, lastName, suffix. and then you have to call the createPracticePerson service.
    For processing the field you will be using simple map processor as you have read earlier. 
    Follow these steps for writing the event:
    1. Process fields coming from the form like: 

    2. Create some Ui labels for showing them in fail-property like PracticeFirstNameMissingError.
    3. Now call service createPracticePerson service by passing out map which is obtained after processing fields as an in map to the service.
      OutPut Screen :

Java Event

Here the java event which you will be writing will be fairly simple. For reference, you can check any of the * files.

  1. The contents will be :

  2. Now you have to process the fields coming from the form like

  3. Now prepare a map for the values which you have to pass to the service which you will call "createPracticePerson" . Like

  4. Then at the end just call the service "createPracticePerson" like

    After writting event in Java don't forget to compile it by running "ant" command. At this moment you will need to add build.xml file to your component directory i.e. at hot-deploy/practice/ For the content of build.xml file you can refer "example" component.
    Here in build.xml file ensure one thing you are having follwing entry:

    This will needed for the classes like

    So create a file by name build.xml and then compile it. It will create a build directory in your component directory which will be containing all *.jar and class files after compilation. For the content of build.xml file you can refere example component. 
    For running the simple event don't forget to make an entry for <classpath type="dir" location="script"/> in ofbiz-component.xml file.
    For running the java event make an entry <classpath type="jar" location="build/lib/*"/> in ofbiz-component.xml file.

Part 4

ECA(Event Condition Action)

ECA : It is a combinition of 3 things: an event, conditions per event, and actions per event. It is a rule used to trigger an action upon the execution of an event when certain conditions are met. When a service is called for example a lookup is performed to see if any ECAs are defined for this event. Events include before authentication, before IN parameter validation, before actual service invocation, before OUT parameter validation, before transaction commit, or before the service returns. Next, each condition in the ECA definition is evaluated and if all come back as true, each action is performed. An action is just a service which must be defined to work with the parameters already in the service's context. There is no limit to the number of conditions or actions each ECA may define.
For more details on this visit :  Service Engine Guide

  1. SECA (Service Event Condition Action) : This is used when we want to trigger another service(action) on the execution of a service when certain conditions are met.
  2. EECA (Entity Event Condition Action) : This is used when we want to trigger a service on the creation of a record for an entity when certain conditions are met.
    For the implementation of ECA again we will be following the same approach for screens, menus by following steps:
  1. Add one more application menu named "ECA" to the practice application's menu bar.(Do the needful entries for target in controller.xml)
  2. Now create another menu called "EcaMenu" in the PracticeMenus.xml file. This menu will have two menu items named "seca" and "eeca". For each of these, two screens will be needed that use the "CreatePerson" form which we created above. (in personForm screen)


  1. For this you have to write another service by name "createPartyRoleVisitor",  which will be setting the role for the party which will be created by "createPracticePerson" service.
    The service "createPartyRoleVisitor" will be triggered by the seca rule which you will define for service "createPracticePerson".
    In the new service involved entity will by "PartyRole". In "createPartyRoleVisitor" just call service "createPartyRole" which is already implemented.
  2. Now you have to create a file by name "secas.xml" in "servicedef" directory. Seca definition will come here. (Take reference from secas.xml of "party" component). This will be

  3. Do an entry in ofbiz-component.xml file for this seca definition to to be loaded. It will be :
    <service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
    Don't forget to restart the server after doing this entry.
    Now run the service through form and check the records in PartyRole entity. You will find a role is set for the party created because synchronously you have triggered another service by seca rule for setting up the role for the party created.


  1. For this, you have to write another service by name "createPartyRoleCustomer",  which will be setting the role for the party which will be created means when a record for the entity "Party" will be created this service will be triggered for setting a role customer for that party. The service "createPartyRoleCustomer" will be similar to "createPartyRoleVisitor".
  2. Now you have to create a file by name "eecas.xml" in "entitydef" directory, which will be in your component directory "practice". Eeca definition will come here. (Take reference from eecas.xml of "accounting" component). This will be :

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

    Don't forget to restart the server after doing this entry.
    Now run the service through form and check the records in PartyRole entity. You will find a role is set for the party created because synchrounously you have triggered a service by eeca rule for setting up the role for the party created.
    The main difference here is that you are triggering a service when an operation is performed on the entity. In our case it is "create".
    Note Here you have created a saparate menu to understand the concept separately. As you written seca for the service "createPracticePerson", so where ever in your practice application you will be calling this service that seca will trigger "createPartyRoleVisitor" and on the other hand when a party will be created "createPartyRoleCustomer" will be triggered.
    Output Screen :


Group Service

    Group services are used to call more then one services as a group. Service groups are a set of services which should run when calling the initial service. You define a service using the group service engine, and include all the parameters/attributes needed for all the services in the group. The location attribute is not needed for groupservices, the invoke attribute defines the name of the group to run. When this service is invoked the group is called and the services defined in the group are called as defined.
For mor details on this visit :
For the implementation of Group service follow these steps:

  1. Add another menu item to applicatoin menu bar by name "Group Service".(Do the needful entries for target in controller.xml)
  2. Now create new screen and a form for creation of the person because the target for the form will be the group service which we will be defining.
    Note : Now the time is to define the group service. We will be defining the group service for the services which we have implemented for this practice application.
  3. You will be defining the service group in services.xml file.(Take reference from services.xml of party component).
    Just write one more service which will be setting the role "CLIENT" for the party which will be created by createPracticePerson Service. 
     Create a group service by name "partyGroup" like :

    Don't forget to restart the server before testing it. 


The interface service engine has been implemented to help with defining services which share a number of the same parameters. An interface service cannot be invoked, but rather is a defined service which other services inherit from. Each interface service will be defined using the interface engine.
For more details on this visit :
For implemeting the interface follow these steps:

  1. Add another menu item to applicatoin menu bar by name "Interface".(Do the needful entries for target in controller.xml)
  2. Create new screen, form and service for creating a person. Here service will implement the interface. (For creating interface take reference from services_fixedasset.xml of accounting component) it will be like :

    Here we are implementing an interface and overriding the behaviour of the attribute "suffix", which will have effect when this service will be in action.
    Implementation of service createPracticePersonInterfaceService will be the same as createPracticePerson.
    Don't forget to restart the server after this implementation.

Part 5

Creating Custom Entity

 For the creation of new entity you can again take a referecne from example component for this you can have a look in entitymodel.xml file of example component. You can create new entities by following these steps:

  1. Create a new subdirectory by name entitydef in hot-deploy/practice/.
  2. Create new file by name  entitymodel.xml. This file will contain the defintions of entities which you want to define.
  3. For loading the defintion you need to do an entry in your ofbiz-component.xml file like:

    That implies that when ever you do a change you need to restart the server to have those changes in effect.
    At this place, an important reading can be found at
    You will rarely find this way to define new entity because you are already having entities there in OFBiz already defined which will be useful for the conduction of your business process. Though you may feel at some place to add more fields to an existing entity so how can you do that? The next  step will show you the way how you can extend an entity for your customized needs.
    Earlier we used to have one more file in the same directory by name entitygroup.xml which not needed any more because code is checked in to the trunk for this.

Extending an Existing OOTB Entity

Yes, you can extend an existing entity for adding more fields to for your custom needs. This can be done in following way:

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

    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 don't forget to go through Entity Engine Configuration Guide

Preparing Data For Custom Application

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

  1. Create new folder in practice by name "data" and create a file in it by name PracticeData.xml.
  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 :

    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.
    You can see Handling of External data#Preparexmlfile for more information on xml structure

  3. Now also add website data here which is as follows:

  4. This data is used for theme setup of a specific application and logged in user can change his theme for the back office application.
  5. Now we have to an entry in ofbiz-component.xml file :

    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/entitymaint and find each entity and check the records have gone in the database or not.

Part 6


This part of the tutorial doesn't work with the latest version of Ofbiz. You can find informations about Ajax Request with this version in the Example component (tab Ajax Examples).

Ajaxify Your Request

What is AJAX: AJAX stands for Asynchronous JavaScript and XML. It is used for allowing the client side of an application to communitcate with the server side of the application. Before AJAX, there was no way for the client side of a web application to communicate directly with the server. Instead, you would have to use page loads. With AJAX, the client and server can communicate freely with one another without page reloads.

In OFBiz we use prototype framework. Prototype is a Open Source JavaScript Framework that aims to ease development of dynamic web applications. Here is the official link: prototypejs

Now lets start with Coding part:

  1. Make entry of /js in allowedPaths of web.xml. So now allowed paths parameter will look like given below:
    1. This will allow .js files which are under /js folder to load.
    2. Step -7 will make you understand more, why we are doing this entry here.

      *Note: * Here you must not miss that this will require a server restart.

  2. Include validation.js and prototype.js in main-decorator in practice/widget/CommonScreens.xml. For this you have to write below given code in <actions> block of main-decorator.
    1. We are including these library files in main-decorator screen, because all other screens uses main-decorator and thus both the libraries will be available in other screens as well.

      validation.js and prototype.js are located at framework/images/webapp/images/prototypejs/

  3. Add another menu item to application menu bar by name "Ajax". Below given is the controller entry:

  4. Create new screen called "PersonFormByAjax" in PracticeScreens.xml. Example code is given below:
    1. PracticeApp.js is the custom js file where we will be writing our custom js code for ajaxifying our request.
    2. person.ftl is the same file we created above.
    3. CreatePerson.ftl is a new file which you need to create now. This file contains form for creating new person, which is same as we created in step-1 of Part-3 under "Writing CRUD operations for Person entity" section. Only difference is that this form is written in freemarker.

  5. Create new file CreatePerson.ftl explained above in practice/webapp/practice/ and place below given code:
    1. Also, notice ids used in this ftl file.
    2. We will be using these ids in our js file.

    3. Click on "Ajax" menu to observe the PersonFormByAjax screen.
  6. Add new div in person.ftl file. Now person.ftl will look like:
    1. Here again, div's id will be used in PracticeApp.js file

  7. Now create PracticeApp.js in practice/webapp/practice/js/ and place the below given code :
    1. Here on first line, Event.observe(element, eventName, handler), registers an event handler on a DOM element.
      1. Argument 1: The DOM element you want to observe; as always in Prototype, this can be either an actual DOM reference or the ID string for the element.
      2. Argument 2: The standardized event name, as per the DOM level supported by your browser. This can be as simple as 'click'.
      3. Argument 3: The handler function. This can be an anonymous function you create on-the-fly, a vanilla function.
    2. So here on window load, an on-the-fly function is called. where form validations and request calling is done.
    3. Important thing to notice is why we write other observation code on window load event, and answer is here we keep restriction, that on window load, all the elements of the form will get activated and then we put observation on form's elements.
    4. In CreatePerson.ftl you see that class="required" are used on forms's input element, You then activate validation by passing the form or form's id attribute as done in second line. More on this can be learned from learn validation
    5. On third line, observer is on "createPerson" which is id of anchor tag (button) in CreatePerson.ftl,
    6. so that when end user clicks "create button" , the instance method, validate(), will return true or false. This will activate client side validation.
    7. And then the createPerson function is called which is out of the scope of window load observer.
    8. In request variable, createPersonForm's action is stored. $('createPersonForm') is again a id of form in CreatePerson.ftl.
    9. new Ajax.Request(url) : Initiates and processes an AJAX request.
    10. The only proper way to create a requester is through the new operator. As soon as the object is created, it initiates the request, then goes on processing it throughout its life-cyle.
    11. Request life cycle:
      1. Created
      2. Initialized
      3. Request sent
      4. Response being received (can occur many times, as packets come in)
      5. Response received, request complete
    12. So here createPracticePersonByAjax request will be called from controller.xml, which will call createPracticePerson service and do needful entries.
    13. Form's elements are serialized and passed as a parameter in ajax request. This is represented in the last line of createPerson function.
    14. Now if response is successful and server has not returned an error, "new Ajax.Updater($('personList'), 'UpdatedPersonList'" will be executed.
    15. Ajax updater, performs an AJAX request and updates a container's contents based on the response text. To get more on this please read : ajax updater
    16. So "personList" is the id of div in person.ftl, which will be replaced by response of UpdatedPersonList request.

  8. Now do required controller.xml entries :
    1. Here you may see that after service invocation request is chained and and is redirected to json request.
    2. json request is in common-controller.xml which invokes common json reponse events and send back json reponses.

  9. Finally create UpdatedPersonList screen in practice/widget/PracticeScreens.xml
    1. This is same as Person Screen
    2. Now this screen will be shown by Ajax updater.

  10. Now submit the form and run ajax request.


  • One important thing to remember is "id" used in form should always be unique. And if you use same id on different elements then prototype may get confused and your javascript will be blocked. these can well observed using firbug.
  • Also installation of firebug is suggested from get firebug, for debugging javascript in Mozilla.

Whats next?

If you have followed all the steps and developed practice application from this tutorial then this will help you in understanding other implementation in OFBiz. These things are basic foundation of working in OFBiz. Now you know, how you can start development in OFBiz. Don't leave behind the extra links provided in this tutorial as they will help you a lot in understanding the things which are given there in detail.
Here is another good reading can be of help is available at FAQ Tips Tricks Cookbook HowTo
Now the next thing comes in the way is the business processes which are really needed to be understood well for understanding OOTB process flow in OFBiz and OOTB data model, so for this, books are available at : OFBiz Related Books. Understanding well the OFBiz OOTB available data model and business processes will help in building better business solutions top of it.

Now you are ready to dive in. Welcome to OFBiz world.


  1. Unknown User (

    in part2's "Doing some advancements",  step5 says: "Now create a new screen by name "person" in PracticeScreens.xml file and also create a new menu item in PracticeMenus.xml file."

    As I am a newer to OFbiz and Freemarker, I have the following questiongs:

    1. I have no idea about how to create a new screen and what contents should I put into the newly-created screen.
    2. how to create a new menu item in PracticeMenus.xml, and what contents should I put into?
    3. how can I make the new menu item in PracticeMenus.xml with the screen with name of "person"?

    Thanks a lot in advance!

  2. sections order:

    In part 2 where it says "Create main Decorator for decorating this application:" we create a main-decorator. However the main-decorator has been referenced earlier in part 1. In part 1 a reference to main-decorator in the example component "CommonScreens.xml" has been given, and then recreated in Part 2.

  3. Unknown User (tanzeem)

    i am trying to get the value of date-time field of my form in my servlet using request.getParameter("dateFrom")

    where dateFrom is defined in my form as

    <field name="dateFrom" title="From Date">
                <date-time type="timestamp" input-method="time-dropdown"  />


    and my service definition is defined as

    <service name="reportServlet" engine="java" location="com.myPackage.MyServletClass" invoke="reportServlet">
            <attribute name="dateFrom" type="String" mode="IN" optional="false"/>
            <attribute name="dateTo" type="String" mode="IN" optional="false"/>
            <attribute name="request" type="javax.servlet.http.HttpServletRequest" mode="IN" optional="false"/>
            <attribute name="response" type="javax.servlet.http.HttpServletResponse" mode="OUT" optional="false"/>


    But i get null value only. How can i get the correct value entered in the form 

  4. Unknown User (

    I've been searching around for two days to get screen widgets to work, with no luck.  After completing step 6 of part 2 I run the request in my browser and get the following error.

    org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen [component://practice/widget/PracticeScreens.xml#person]: java.lang.IllegalArgumentException: Could not resolve location to URL: component://practice/widget/CommonScreens.xml (Could not resolve location to URL: component://practice/widget/CommonScreens.xml)

    I can't find much information on how widgets work in OFBiz.  Any help would be much appreciated.

    1. I solved the problem by changing the path to component://practice/webapp/practice/widget/PracticeScreens.xml#person

  5. The following link may be useful if you want to provide helpful tooltips in your forms -

  6. Hi,

    I have a little doubt here. Suppose i want to write test case for this module how can i write it? As what i know most of the code is in xml format only (and not in java). So if some one will ask to find out code coverage how can i find out? Supposing i have to enhance code coverage than how can i do that? Do i have to find coverage for java classes first or for xml? If it's for xml than how can i find coverage for xml? Waiting for reply.

    1. To Ron and Sharan: please verify that we have not a such page or entry in FAQ in wiki, I think we don't, then we could add one indeed, thanks!

  7. Part 2, Step 2
    There needs a small change to display the "main" menu correctly...

    <menu-item name="main" title="Main"><link target="main"/></menu-item>

    Changed to
    <menu-item name="practicemain" title="Main"><link target="main"/></menu-item>

    Since "component://common/widget/CommonMenus.xml" also has a "main" menu item, there will be a conflict and the practice screen's "main" menu does not get displayed when you enter the URL http://localhost:8080/practice/control/person

    1. Is this wrong? If not why it has not been fixed for 3+ years?

  8. I have updated the introductory section to fix missing links and to clean up some English. Stopped at the beginning of part 1.
    Comments welcome! 

    1. Hi Ron,

      Updates you made are looking great. Thanks for the effort.


  9. Hi Ron,

    Reviewed updates, these are looking great. Thanks so much.

    As you move further, you may need to check correctness of given code snippets as well at some places. This is required as its haven't been checked since long over release 13.07 or trunk code.

    Please let me know in case you need any help. 


  10. Not looking at code since I have no eperience in this area.