(→How to change an already created object)
(→How to remove created objects)
|Line 113:||Line 113:|
==How to remove created objects==
==How to remove created objects==
Revision as of 17:19, 22 February 2010
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 into the database, 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 one single window: the Easy Extensible Attributes window, which can be found in General Setup/Application.
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 or specify the module to extend: The new objects will be created inside a module which needs to be created by the user. The next section in this user manual will cover this topic
- 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 and all the physical database objects.
- 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.
Initial requirement: Creating a module
This module creates Application Dictionary and database physical objects. As you know, the correct way to create these objects is to use a module which will contain them. Therefore, the main requirement to use this module is to have your own customization module.
You can choose to create the module manually through the application, or you can use the built-in tool to do so.
Creating the module manually has the advantage that you can choose your own name, javapackage, dbprefix, ... However, if you do it this way you must make sure that you create the module correctly. This means that you must make sure that:
- The module has a defined database prefix.
- The module has a defined datapackage.
- The module has the "Translation required" setting set as "yes".
- The module is set as "In Development"
If you want to use the built-in tool, you just have to select the "Create standard module" checkbox that appears just beside the Module menu, in the Easy Extensible Attributes window.
Specially for new users, it's recommended to use the built-in tool to create the module.
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 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 physical database column, and 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).
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.
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 database. 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 database. If you check the property and run the process again, the objects will be recreated.