Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Corrected some typos and grammar.

...

Note - 1 :- For any additional query and concern you can consult to Example component. You will always find the code in example component to be the most latest code of OFBiz. Take reference whenever you want to see some sample code for the development of this application.
Every new feature is first added in the Example component for the references.
Note - 2 : Before starting the development of this application you must read the contents form from:
http://docs.ofbiz.org/display/OFBADMIN/OFBiz+Contributors+Best+Practiceshttp://docs.ofbiz.org/display/OFBADMIN/Coding+Conventions and http://docs.ofbiz.org/display/OFBADMIN/Best+Practices+Guide
Note - 3 : Don't copy any file from other component, as the revision number for the file is also copied. Always create a new file and, if required, then copy the contents of the file." Also be conscious about the unused code as well.
Note - 4 : For searching any of the document the best place is at : http://docs.ofbiz.org/display/OFBADMIN/OFBiz+Documentation+Index .
Note - 5 : Right from the beginning, reading the console log must be in be a habit to make trouble shooting troubleshooting easy and to understand understanding the system well.

Create first basic application by name "practice" :

Step - 1 : Create the sub-directory in hot-deploy/ and name it "practice"(hot-deploy/practice). The directory name should match the new components name that we are creating.
Note : Remember that all customized development is done at this place only. 
Step - 2 : Create the ofbiz-component.xml file on path hot-deploy/practice and place the following content in it (for reference you can check this file in any other component of OFBiz):

...

1. The ofbiz-component.xml file is responsible for letting OFBiz know where resources are at as well as allowing you to add to the classpath.
2. Here  The 'resource-loader name' can be any string here it is . Here we are setting it as "main". The 'type' tells OFBiz that we will be loading a component.

...

Step - 6 : Move up one level and create a new directory named 'error'(hot-deploy/practice/webapp/practice/error).
Step - 6.a : Create a file error.jsp inside the "error" directory. Contents of this file can be taken 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.
Step - 7 : Create a sub-directory inside your component directory "practice" named "widget"(hot-deploy/practice/widget).
              This directory will contain your forms and screens which will be created for UI.
Step - 8 : Create a file inside the directory "widget" named "PracticeScreens.xml".
 Contents of this file can be taken from any of the existing component  e.g. example component.
As now onwards you will be able to create screens views so an important reading at this place will be Best Practices Guide . On this page there links to following:

  • HTML and CSS Best Practices
  • Managing Your Source Differences
  • Methodology Recommendations
  • User Interface Layout Best Practices
    All these readings will be really of help.
    Very first screen will be like :
    Code Block
    <?xml version="1.0" encoding="UTF-8"?>
    <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
        <screen name="main">
            <section>
                <widgets>
                    <label text="This is first practice"/>
                </widgets>
            </section>
        </screen>
    </screens>
    

...


Step - 4 : Do the needful for showing this screen in controller.xml.
Now run the application again and observe the difference.
Till Now you have worked on controller requests mappings, Screen widget, form widget, Decorator, Menus, groovy, ftl.

Create main Decorator for decorating this application:

...


Step - 2 : Now include this decorator in CommonPracticeDecorator screen which you are already having.
Now run it again and see the difference.

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

...


similar for Update and Delete 
Step - 3: 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.
Step - 4 :  Create controller entries for these services which are going to be called by this form.

Writing Events:

Events can be written in Java and minilang both. Now the next development which you are going to do will be writting 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 : http://docs.ofbiz.org/display/OFBIZ/Mini-Language+Guide#Mini-LanguageGuide-smapFor making an understanding with it implementation will be done by performing following steps:
Step - 1 : For this create another tab in your practice application menu bar for this by Name "Events".
Step - 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.
Step - 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.

...


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 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 :  http://docs.ofbiz.org/display/OFBTECH/Service+Engine+Guide
For the implementation of Group service follow these steps: 
Step - 1 : Add another menu item to applicatoin menu bar by name "Group Service".(Do the needful entries for target in controller.xml)
Step - 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.
Step - 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 :

...