Purpose of the module
One of the most common development activities in Openbravo is to create a new tab which allows the user to add, modify and delete new information, or to add additional fields to existing tabs. Following Openbravo's Model Driven Development, these processes require the user to create Application Dictionary components for each tab and field he wants to add. The creation of these objects can sometimes be difficult, as lots of properties need to be specified, and some concepts that need to be taken into account, such as Modularity Naming Rules, can be complicated to some non-advanced users.
Moreover, these processes also require the user to add database physical objects (tables and columns) which correspond to the added tabs and fields. These objects are normally created directly through the Database Management System, and not through Openbravo, and this involves an additional step that can also be very difficult to non-advanced users.
The main purpose of this module is to centrallize all the information which is needed for these two common processes, and to greatly simplify the whole process. This module will therefore allow the user to:
- Create a customization module which will contain all the created objects
- Choose an existing tab in the application, or specify the information needed to create a new one
- Specify the information needed to create a new field from scratch, or choose one from a list of predefined Field Templates (which will be the most common cases of newly user created fields).
And after that, it will:
- Create all the necessary objects in the database (both application dictionary objects and database physical objects) automatically, through a process that is triggered by a single user click.
- Allow the user to initiate the rebuild of the system, which will complete the process (this is necessary to compile the newly created and the modified windows again)
High level summary of the whole process
All the functionalities which the Easy Extensible Attributes module provides can be accessed through two different windows: the Easy Extensible Attributes window, which can be found in General Setup/Application, or the Easy Extensible Attributes for developers, which can be found in Application Dictionary.
You should use the first window if you are a user which doesn't want to be bothered by advanced development concepts such as modularity. The second window is designed for developers, and allows you to specify a development module in which the new Application Dictionary will be added (the first one automatically creates a customization module, and adds the objects there).
The process the user needs to follow to create or to extend new tabs has several steps. This is a short description of every one of them:
- Create a new record in the Easy Extendable attributes window: In this record, you specify whether you want to create a new tab, or extend an existing tab. If you want to create a new tab, you need to provide some additional information.
- Create new records in the Field tab of the Easy Extendable Attributes window: In this tab, you need to create a new record for each additional field you want to create.
- Apply the changes to the Application Dictionary: This process is called from a button in the Easy Extensible Attributes window, in the "Window" tab, and creates all the objects in the Application Dictionary.
- Rebuild the system: This final step involves recompiling the application and restarting tomcat. This can also be called directly from the Easy Extensible Attributes window.
These are the steps you need to follow to create the tabs and fields. In the subsequent sections of this guide we will explain each one more in detail.
First step: create a new tab or specify an existing tab
The first main step in the process is to create a new entry in the Easy Extensible Attributes window. In this record, you specify:
- The module in which all the objects will be created (must be the module you created in the previous step)
- The window you want to extend
- Whether you want to extend an existing tab of this window, or create a new one in it.
If you choose to extend a tab, you will need to specify the existing tab you want to extend:
and after selecting the correct tab, you are done with this step, and you can continue with the next one.
If instead you want to create a new tab, you need to provide a little bit more information:
- The tab name will be used also (with correct adjustments to take into account Openbravo naming rules) for the physical table name, and for the Java DAL entity created for the table.
- The child of tab can be left blank. If you choose one tab, the new tab will be created as a child of the selected tab. If this is the case, there will be a direct relationship between the entities you create in your tab, and the entities of the parent tab (each entity created in the child tab will have a parent).
- The after tab is used to position the new tab in the correct place in the Tabs bar.
How to create new fields
Once you have created a new record in the Window tab of the Easy Extensible Attributes module (either to create a new tab, or to extend an existing tab), the next step is to specify the new fields you want to create.
To do this, you need to create one record in the "Fields" tab for every field you want to add to the tab.
You can follow two main paths when creating a field:
- You can choose to insert all the necessary data manually.
- Or, you can choose to use one of the proposed Field Templates.
If you select one of the field templates, the name and the field type of the field will be automatically set up for you. The basic options in a field are:
- Name, description, help: basic information about the field
- Field type: the kind of data this field will contain, which in turn influences how it will be shown in the window
- Column size: the size of the data this field will store
- Field size: the length of the field which is shown in the window, measured in columns (1, 2 or 5)
The Show Details check activates several additional options for the field:
- Default value: This is the default value for the field. This default value will be used both in the column defined in the application dictionary.
- Mandatory: Whether the field is mandatory or not (that is, if the user is required to set a value for it).
- Read only: Whether the user can modify the field's value, or instead he can only read it.
- Used as record identifier: Whether the field is used as the identifier for the whole record.
- Used as filter column: Whether the field is shown when filtering the tab (in the window shown when the "magnifying glass" button in the toolbar is clicked)
- Default tab sort criteria: Whether the field is used to sort the records in grid view by default
- Place at the end: Whether the field should be placed at the end or not. If it's not checked, a menu which allows the user to select after which field the new field should be placed will appear.
- Same line as previous field: Whether the field should be placed at the same line as the previous field, or at the beginning of the next line.
- Show in grid view: Whether the field should be shown in grid view.
- Start new group: Whether a new field group should be created just before the new field. If this property is checked, the user needs to enter the name of the group.
- First focused field: Whether this field is the first focused field of the tab (that is, if the cursor is placed at this field when the tab is opened).
Important note: Every tab you create needs an identifier field. This means that one of your fields must have the "Used as record identifier" property checked.
Applying the changes to the Application Dictionary
After you've created one record for every field you want to create, you are ready to apply the changes to the Application Dictionary. To do this, return to the "Window" tab in the Easy Extensible Attributes window, and click on the "Apply changes to the Application Dictionary" button.
This process will create the new application dictionary objects and database physical objects according to the information you provided in the previous steps.
Rebuilding the system
After the changes were applied to the application dictionary, the system needs to be rebuilt. This can be done directly also in the "Window" tab of the Easy Extensible Attributes window, by clicking in the "Rebuild system" button.
After you have rebuilt the system, and restarted Tomcat, the modifications you've made should be fully available in your system (the fields you've added and/or your new tabs should be available in Openbravo).
Basically, at this point, you're done!
How to change an already created object
After you've run the "Apply changes to application dictionary" process, the objects have been created in the database. However, you can still modify them. If you want to do it, you can just modify any property in the "Window" or "Field" tabs in the Easy Extensible Attributes window, and click on the "Apply changes to application dictionary" button again. The objects will be updated to reflect your changes.
How to remove created objects
After you've run the "Apply changes to application dictionary" process, the objects have been created in the Application Dictionary. If, for some reason, you want to remove them, there is a way. The records in both the "Window" tab and the "Field" tab of the Easy Extensible Attributes window have an Active property. If you uncheck this property, and click again on the "Apply changes to application dictionary" button, the related objects will be removed from the Application Dictionary. If you check the property and run the process again, the objects will be recreated.