Versions Compared

Key

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

...



a) name :- defines the name of our web application.
b) title :- This will be the title of our component
c) server :- This will let 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.
e) location :- This will be the location that is the default base directory for the server
f) mount-point :- This is the URL used to access this resource. in this case it would be localhost:8080/practice
g) app-bar-display :- This will let OFBiz know if we want our component to show up in the main application tabs that are part of the common ofbiz decorator. 

Creating the web app:

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

...

Step - 4 Create a file named "web.xml"(web.xml follows j2ee webapp specs). Contents of this file can be taken from any of the existing component e.g. example component. The Important values to change are the <display-name>, the localDispatcherName, and the mainDecoratorLocation.

    

   

Code Block
     <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>   param> 

  
    

Code Block
        <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>


For now put the value: "component://practice/widget/CommonScreens.xml" in for the location and you will see why in a while. This location is used in pointing to the main decorator location in screens like

...

. Which increases the code Independence from changing the path at many places when we need to change the main decorator location. At that time we just need to change the location there only and will work for all the screens where it has been used. One more advantage of doing this in screens is the purpose of resuability of existing screens which we can use from other components, but it decorate that screen by your decorator only as the same pattern is used at all the places and in all the components to show the mainDecoratorLocation. Concentrate on this when you add decorators in your screens in not too distant future with the development of this application.

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

...



Step - 9 : Now that we have the basic elements in place lets 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. Because in our ofbiz-component.xml file we said our webapps 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 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.

...