Tutorial : Task List
Contents |
[edit] Task List
This tutorial demonstrates the use of a collection to store multiple records.
The finished application will look like this:
[edit] Related Resources
- For a detailed introduction to Bungee Builder, see the Introduction to Bungee Builder tutorial, which combines a guided tour of Bungee Builder with the Hello World tutorial.
- For documentation on Bungee Builder, see the BCDN documentation wiki.
[edit] How to use this Tutorial
This tutorial is written for developers that are somewhat familiar with the basics of Bungee Builder. If you would like more detailed steps on working inside Bungee Builder, check out the Introduction to Bungee Builder and Hello World Tutorial before proceeding with this tutorial.
Throughout this tutorial, there are links to reference documentation on Bungee concepts:
- Most numbered steps link to the relevant document on how to accomplish the given task. Use these links for more information on how to perform a given task (for example, how to add a class to a project).
- Beneath the steps are links to the relevant concept documents. Use these links for conceptual information on the object being used (for example, what is a class?).
[edit] Procedure
- Create a new solution and TypeLib
(Concept: Understanding Solutions and Projects)
- Solution name: QuickTaskList
- Project type: TypeLib
- Project name: QuickTaskList
- Add a class to hold the description of each the task (clsTask)
(Concept: Understanding Classes)
(Concept: Understanding Fields)
(Concept: Understanding Forms)
(Concept: Understanding Controls)The first object to add is the class for the task. This class holds the primary data and basic form for the project.
- Add a class to the project
- Name: clsTask
- Add three fields to the class
- string description (to hold the description of the task)
- Type: string (default)
- string dueDate (to hold the task's due date)
- Type: string (default)
- boolean complete (to be linked to a checkbox showing whether completed when a task object appears on a form)
- Type: boolean ((under TypeLib: QuickTaskList > Dependencies > Runtime > TypeLib: Types)
- string description (to hold the description of the task)
- Add a form for displaying tasks (frmTask)
- Name: frmTask
- Layout:
- Three columns, one row
- Add controls to the form
- Add a Checkbox
Technical Note A Checkbox control can be bound to various types of data (numeric, sting, and boolean). When implementing a Checkbox control, you must set the values for the Value When Selected and Value When Not Checked properties. When binding a Checkbox control to a Boolean, the Value When Selected property is set to true by default. When the Checkbox control is bound to a numeric or string, the field type determines the set of allowable values. Be sure to set the Value and Toggle Value properties to the appropriate values. For enumerated fields, the Value and Toggle Value properties are set from an enumerated list
- Location: Left column
- Binding: boolean complete (in clsTask)
- Label: None (remove text from text box)
- Size: Reduce column width to just larger than the checkbox (22 pixels)
- Add a Label
- Location: Center column
- Binding: string description (in clsTask)
- Size: 120 pixels)
- Add a Label
- Location: Right Column
- Binding: string dueDate (in clsTask)
- Size: 40 pixels
- Add a Checkbox
- Add a class to the project
- Add a class for listing multiple task objects (clsTaskList)
(Concept: Understanding Classes)
(Concept: Understanding Fields)This class holds a collection of tasks. It uses the previously created class as the type.
- Add a class to the project
- Name: clsTaskList
- Add a field to the class
- Collection(clsTask): TaskList (collection of tasks)
- Type: clsTask
- Select Is Collection
- Collection(clsTask): TaskList (collection of tasks)
- Add a class to the project
- Add the main class for the project (clsMain)
(Concept: Understanding Classes)
(Concept: Understanding Fields)
(Concept: Understanding Bungee Logic)Now that you have created a class for an individual task, a class for storing multiple individual tasks, and a Datasource in which to store the list of individual tasks, you can create the main interface and program logic for a basic task list.
- Add a class to the project
- Name: clsMain
- Add a field to the class
- clsTaskList savedTaskList
- Type: clsTaskList
- Add a field to the class
- clsTask inputTask
- Type: clsTask
- Add a class to the project
- Create the primary user interface for the project
(Concept: Understanding Forms)
With the data structures for clsMain defined, you can create the primary user interface for the project.
- Add a form to the clsMain class
- Name: frmMain
- Layout
- One column, two rows
- Width: 400 pixels
- Height of top row: 55 pixels
- Add controls to the form
- Add a Grid control to top row
- Layout: Three columns, two rows
- Column widths:
- Column 1: 160 pixels
- Column 2: 160 pixels
- Column 3: 120 pixels
- Column widths:
- Add a Label to Grid
- Location: Left column, top row
- Binding: None (drag Label from Text category)
- Text property: Description
- Add a Label to Grid
- Location: Center column, top row
- Binding: None (drag Label from Text category)
- Text property: Due Date
- Add TextEdit control to Grid
- Location: Left column, bottom row
- Binding: string description (under clsTask inputTask)
- Add TextEdit control to Grid
- Location: Center column, bottom row
- Binding: string dueDate (under clsTask inputTask)
- Add a DynamicFormList control
- Location: Bottom row of form
- Binding: Collection(clsTask): TaskList (under clsTaskList savedTaskList)
- Add a form to the clsMain class
- Implement a form adapter for displaying saved tasks
(Concept: Understanding Adapters and Connections)
To enable the DynamicFormList to display multiple saved tasks, you need to create a form adapter. The form adapter re-uses the clsTask frmTask form and displays it in the DynamicFormList for each individual task that the user has saved. To implement the form adapter, you create a the form adapter, set frmTask to use the Form Adapter, and then set the form adapter to act as the Element Form for the DynamicFormList. (A list is comprised of multiple list items, or elements, so a form list is comprised of form elements.)
- Add a form adapter to the project
- Name: TaskListFormAdapter (sets which form is displayed by the DynamicFormList control)
- Type: Form Adapter
- Add the form adapter to frmTask (in clsTask)
- For the Adapter List property, add FormAdapter: TaskListFormAdapter (under TypeLib: QuickTaskList)
- Set the Element Form Adapter for the DynamicFormList control (on frmMain in clsMain)
- For the Element Form property (under Adapter), add FormAdapter: TaskListFormAdapter (under TypeLib: QuickTaskList)
- Add a form adapter to the project
- Create a function in the clsMain class for adding tasks
(Concept: Understanding Functions)
You now need to create a function that adds data from the inputTask field to the clsTaskList (and thereby stores it in clsTaskList DataSource). After adding each inputTask field into the task list, you want to create a new inputTask that is empty and ready to receive input for another task.
- Add a function
- Name: addTask (writes the tasks to the datasource and then clears the input fields)
- Edit public addTask
- Add call function ()
- For Function Path:
- Type: Path
- Select Function: add (under clsTaskList savedTaskList > Collection(clsTask): TaskList)
- Parameter
- Type: Path
- Select clsTask inputTask
- For Function Path:
- Add assignment
- Left side:
- Type: Path
- Select clsTask inputTask
- Right side:
- Type: Object
-
Set new object:
- Set boolean complete to Data
- Set string description to Data
- Set string dueDate to Data
- Left side:
- Add call function ()
- Add a button to call the function
- Form: frmMain
- Location: Right column, bottom row of Grid
- Binding: addTask
- Button Label property: Add Task
- Add a function
- Run the form
(Concept: Understanding Simulate)
- Add several tasks to your project. Mark some tasks as complete.
- Close your running project and immediately re-run it. The items previously added (and whether they're marked as complete) will not be displayed. It was lost when you closed the previous session. To persist data across sessions requires a datasource. If you would like to try this project with persistent data, we recommend trying the Task_List with Datasource tutorial.