Versions Compared

Key

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

...

If a large set of code needs to be added or changed in a a specific component in an existing OFBiz OOTB component where you will add more entities, services, screens, forms etc. then this strategy should be adopted and complete component should be overridden in hot-deploy directory.
Following steps need to be performed for overriding an existing component:

  1. Create custom component in hot-deploy directory by any name same as one you want to override, its just going be replica of existing OOTB OFBiz component with all the major directories and files required for setting up a component.
  2. You can use ant create-component target on OFBiz root directory to create this component in hot-deploy directory.
  3. Only those files need to be added which you need to have in overriding the component, webapp. Rest of the resources are going to be used from OOTB component so if you have used ant create-component target then you can safely delete some of the files like if you are not going to write a service then services.xml file can be deleted, or if you are not going to add or extend an existing entity then you can delete entitymodel.xml file and their entries from ofbiz-component.xml file of custom component.
  4. Basically this is the thin line between extending a webapp and a component. If you are going to have major changes in services and entities then creating a new component should be preferred where you will be extending the existing webapp.
  5. e.g. If you want to have a separate component for adding or extending existing functionalities from catalog application which is a webapp in product component then you can have component in hot-deploy dir by extending the catalog webapp from product component.
  6. Follow below given points:
    1. Make sure to properly override the webapp in ofbiz-component file of custom component as example given below:
      Code Block
      <webapp name="catalog"
          title="Catalog"
          server="default-server"
          location="webapp/catalog"
          base-permission="OFBTOOLS,CATALOG"
          mount-point="/catalog"
          app-bar-display="true"/>
      
    2. Make sure to make entries of custom service defs(if-any), entity defs(if-any) and data files(if-any) in ofbiz-component file of custom component as example given below:
      Code Block
      <entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
      <entity-resource type="data" reader-name="seed" loader="main" location="data/*TypeData.xml"/>
      <service-resource type="model" loader="main" location="servicedef/services.xml"/>
      
    3. Make sure to have same web.xml file from existing webapp.
    4. You can have new main-decorator defined for screens in webapp so if this is the case this needs to be changed in web.xml.
    5. Make sure to have controller.xml file in new webapp created and include the the controller from existing webapp and only include custom requests only rest will be taken care by included controller only, as shown bellow:
      Code Block
      <include location="component://product/webapp/catalog/WEB-INF/controller.xml"/>
      
    6. Make sure to have error.jsp inside extended webapp.
    7. Make sure to have index.jsp file with redirect path.

...

  1. Follow below given points:
    1. Add webapp which you want to override from existing OOTB OFBiz component with the one that you already have in your webapp dir.
    2. Make sure to properly override the webapp in ofbiz-component.xml file of custom component with the webapp that you already haveas have as example given below:
      Code Block
      <webapp name="catalog"
          title="Catalog"
          server="default-server"
          location="webapp/catalog"
          base-permission="OFBTOOLS,CATALOG"
          mount-point="/catalog"
          app-bar-display="true"/>
      
    3. Make sure to have same web.xml file from existing webapp.
    4. You can have new main-decorator defined for screens in webapp so if this is the case this needs to be changed in web.xml.
    5. Make sure to have controller.xml file in new webapp created and include the the controller from existing webapp and only include custom requests only rest will be taken care by included controller only, as shown bellow:
      Code Block
      <include location="component://product/webapp/catalog/WEB-INF/controller.xml"/>
      
    6. Make sure to have error.jsp inside extended webapp.
    7. Make sure to have index.jsp file with redirect path.
    8. Here for other resources which you would like to add or extend like servicedefs, entitydefs or data files you can use the custom component's directories to add them. Make sure to do entries of these resources in ofbiz-component.xml file of your component to load them.