Adding Basic Structure using Class Designer
Creating new classes and adding fields to it using the Class Designer.
Last updated
Creating new classes and adding fields to it using the Class Designer.
Last updated
The first step in building every application is to create a structure in the Class Designer.
For in-depth documentation about data modelling, you can also check out the Data Modelling page.
To add a new class, while still being in the Config Mode of your application, click on Classes, then in the next window click on New Class.
We can now configure our new class in the new window.
Choose a unique name for both the Key and Name fields, for example, "MyToDo". Under Class Type, we also need to check the Is Independent and Auto-Save checkboxes. We will refer to this class as the To Do Class in this tuitorial.
When Auto-Save is checked, user changes are saved automatically.
Key is the name we use to this specific class on the TIVITY platform.
Name is what is displayed to the user.
The Key in the Mapping Tab represents the name of the table in the database.
It is important that the key with the table name does not already exist in the database. Otherwise you will get errors. See chapter: Write structure.
For this tutorial, no changes are required in the Advanced Tab or the Permissions Tab, so we can move on directly to the Fields & Actions Tab.
As its name suggests, this tab allows us to create new fields and actions. Some fields and actions are already present by default.
To start adding a field to our class, type your field name in the Add new field text box and press Enter.
Each field has a Key, an Internal Key, and a Name. They also have a Data Type to describe what kind of data is present in the field and a Control Type to define what kind of Control to use for data input.
Settings on this tab are used to configure the mapping from our field to the database. Once again we need to define a Key.
Data Type and Length describe the type of data and its size respectively when stored inside the database.
Assigning a value of -1 to Length instructs the database to use the maximum length for the data type specified.
Finally, the Is identity checkbox indicates whether the database should auto increment the value of the field, and Is nullable indicates if this field can be null.
We will be adding the following fields to our class :
The first field we are going to add to our class is the "Title" field which will store the title of the task.
In the Common Tab :
In the Mapping Tab
The "Notes" field will store notes that we can attach to our tasks.
In the Common Tab :
In the Mapping Tab
In the "Priority" field, we will store the priority of the task. This time we want our field to have only 3 possible options: "Normal", "Medium" and "High". To achieve this, we will set the Data Source Type as Options and list our possible values.
We also want to use a slider to set the priority of the task, so we set the Control Type to Slider.
We also want our task item to have a default priority "Normal" when created, so in the Advanced Tab, we set the Default Mode to "Creation" and the Default Expression to "Normal"
In the Common Tab :
In the Mapping Tab
In the Advanced Tab
The CreatedOn is a special field which the platform automatically detects it and is automatically set to the corresponding date and time when an object is created.
Make sure to spell "CreatedOn" correctly for this feature to work!
We also do not want anyone to modify this field, so we check the Is Read Only checkbox in the Advanced Tab.
In the Common Tab :
In the Mapping Tab
In the Advanced Tab
The "DueDate" field will allow the user to input a due date for the task using the Calendar control.
In the Common Tab :
In the Mapping Tab
The is completed field will indicate whether the task is completed or not.
In the Common Tab :
In the Mapping Tab
In the Real Field
ModifiedOn is a special field that is automatically detected by the platform and is automatically set to the date and time when an object is modified.
We also want that field to be read-only.
In the Common Tab :
In the Mapping Tab
In the Advanced Tab
CreatedBy is a special field that is automatically detected by the platform and is automatically set to the unique identifier of the current user when an object is created.
This field is set to read-only.
In the Common Tab :
In the Option Source :
In the Mapping Tab
In the Advanced Tab
For this tab we want the user to be able to assign ownership of the task by picking any user in the workspace. The TIVITY platform has a predefined implementation for this kind of operation called a Controller.
For this field, we use the "Combo Box" Control Type, and to populate it with users of the workspace, we set the Data Source Type as Controller and the Data Source Controller as OfficeUserIdSourceController
When created, we also want the default owner to be the current user if no one user been specified. To achieve we, we go head to the Advanced Tab and set the Default Mode to Creation and the Default Expression to {CurrentUser.Id}
In the Common Tab :
In the Mapping Tab
In the Advanced Tab
ModifiedBy is a special field that is automatically detected by the platform and is automatically set to the unique identifier of the current user when an object is modified.
This field is set to read-only.
In the Common Tab :
In the Mapping Tab
In the Advanced Tab
Now having created all the fields, we can save our class by clicking on the Save button.
TIVITY will validate all fields and give out warnings if any errors are present in the class.
Now a physical structure of the newly created and configured class must be created. For example, in the case of an SQL database, a table is created in the database as a data source in which the instances of this class can later be stored.
The action to create the structure is located in the upper right corner of the designer. Open the menu there and select the action Write Structure.
The action Read Structure executes the reverse way. The structure is transferred from the data source and the classes are updated or created in the Designer. For example, in SQL database as data source changes of a table (new column added) is transferred to the class model.
If a newly created class already exists or fields are duplicated, a validation error occurs.