Versions Compared

Key

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

...

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 OfbizOFBiz. 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 :
            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

...

1. The ofbiz-component.xml file is responsible for letting ofbiz OFBiz know where resources are at as well as allowing you to add to the classpath.

2. Here 'resource-loader name' can be any string here it is "main". The 'type' tells ofbiz OFBiz that we will be loading a component.

...

    c) server :- This will let ofbiz OFBiz know what server to use 

    d) base-permission :- This line requires that the user should have the OFBTOOLS permission to be able to use the application. Since the 'admin' user has this permission we do not have to create any new users. 

...

    g) app-bar-display :- This will let ofbiz OFBiz know if we want our component to show up in the main application tabs that are part of the common ofbiz decorator.  

...

Step - 2 : Create a sub-directory inside the webapp directory by the name of  "practice" which is the name of the webapp which you are going to develop (hot-deploy/practice/webapp/practice). A component can have multiple webapp's webapps attached to it. e.g. In the "marketing" component there are two webapps "marketing" and "sfa".
The webapp we are creating will follow the J2EE webapp standards.

...

"localhost:8080/practice/control/main"

1- When ofbiz OFBiz sees this request it will look at the /practice section first. Because in our ofbiz-component.xml file we said our webapps mount point would be /practice. Now ofbiz OFBiz knows that our practice component will handle the rest of the request.

2- Ofbiz OFBiz will then look at our controller.xml file. Inside our controller.xml file we have request-maps and view-maps. If it finds a view-map with the name 'main' it will go there. 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.

...

Step - 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, but because of deprecation of bsh files we are using this groovy files.
Reference : Tips & Tricks while working with Groovy & []http://wwwgroovy.beanshellcodehaus.org/docs. html. While working in bsh groovy always be conscious about the imported classess classes and packages. Import only those which have been used in your file. For putting log messages use methods from "Debug" class just do this practice from the begining beginning itself.
so create a file by name personPerson.bsh groovy in this  actions directory which will be fetching all the records from the entity "Person".Now a new scripting language has been introduced in place of bsh script the name is "groovy". For more info you can visit : http://groovy.codehaus.org/ An important reading for this is at : Tips & Tricks while working with Groovy

Step - 4 : Now in webapp "practice" create one ftl file by name "person.ftl" which will be used to show the data fetched by bsh groovy file.
               Reference : http://freemarker.sourceforge.net/docs/

...

Till Now you have worked on controller requests mappings, Screen widget, form widget, Decorator, Menus, bshgroovy, ftl.

Create main Decorator for decorating this application:

...

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  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: Include this Ui Label resource in your main decorator screen which you created earlier and use these one or two Ui ui labels which you are having now.

...

 Note: At this place you must read http://www.nabble.com/The-fancy-new-entity-auto-service-execution-engine-td18674040.html. This feature has been recently added against the traditional approach of writing CrUD CRUD operations for an entity.

...

The file name will be PracticeEvents.java and will be creted created at  practice/src/org/hotwax/practice.

...

The event which you will be writting writing should be the simple one as you just have to process 5 fields comming 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 writting writing the event:

7.a : Process fields coming from the form like: 

...

Here the java event which you will be writting writing will be fairly simple. For reference you can check any of the *Events.java file.

...

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

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

...

 Create a group service by name "partyGroup" like :

<!-- Group service -->
    <service name="partyGroup" engine="group" auth="true">
        <description>Creates a party, person and party role Client</description>
        <group>
            <invoke name="createPracticePerson" result-to-context="true"/>
            <invoke name="createPartyRoleClient"/>
        </group>
    </service>

...