
For version 2.1 (16 Dec 2008): This tutorial aims to get you going in Habanero as quickly as possible.
Here we will cover the most important "hows" but not the "whys". Move on to
the full tutorial when you want to understand how to use new features and
why they work the way they do.
Installation
Download the latest version from the Habanero website.
When you open the zip you will find:
- Habanero MSI - run this.
- Firestarter MSI - run this.
- TutorialProject - unzip this.
- HabaneroTutorial - the full tutorial, come back to it later
Also check that you have installed:
- Microsoft .Net Framework v2
- Visual Studio or an IDE that can load solution files
- A database vendor. Firebird is self-contained, but MySQL administrator and others may need an installation.
Test Your System with the TutorialProject
- Go to the TutorialProject and open the solution (.sln) under the source folder
- Set the startup project as Replace_it (right-click on the project name and "Set as Startup Project")
- Open app.config and change the REPLACEIT.FDB database value to that file's absolute path
- Run.
- If you get an error "The given key was not present", restart the application
- If there are other errors, let us know through the Forum
Run the application in a web browser:
- Set Replace_it.VWG as the startup project
- Copy the changes you made to app.config into web.config
- Run.
You can also run this project using MySQL:
- Restore the backup in the database folder
- Change the commenting in the app.config/web.config to use the new database
- Add references to MySql.Data.dll (available in the lib folder) to your startup projects
- Run.
Create a New Firestarter Project
Open Firestarter, go to File > New and create a new Firestarter project called MyProject.
We will now create an application with no database, using an in-memory database instead.
Note: you could skip this step by reversing-engineering from a database
(go to Generate > Class Defs from Database).
Let's create a working BusinessObject class:
- On the Classes tab, click New
- Click ... next to Assembly Name and create one (MyProject.BO)
- Set the Class Name as MyClass
- Change to the Properties tab
- Add a property called MyClassID and set the type to Guid
- Add a property called MyProperty and leave the type as String
- Change to the Primary Keys tab
- Double-click on MyClassID
- Change to the Uis tab
- Click on "New UI"
- Under the Grid tab, click on Multi Select and double-click MyProperty
- Under the Form tab, do the same
- Save your project
Generate the Solution
- In the menu, go to Generate > Generate Code
- Set the Habanero dll path to the bin folder of your Habanero installation (probably C:\Program Files\Chillisoft\Habanero 2.1)
- Change Project Type to "Windows Web Dual"
- Click "Auto Create Project Naming"
- Click Generate
We need some useful visual output, so let's generate a form:
- In the menu, go to Generate > Generate Forms
- Set the form type of MyClass to "Read-only Grid"
- Click "Generate Forms"
Run the Solution
- Open the newly generated Solution (.sln) file.
- MyProject.Win should be highlighted as the startup project (if not, then set it so)
- Open app.config in MyProject.Win and set the "vendor" as "inmemory"
- Open Program.cs in MyProject.Win:
- Add at the top:
using Habanero.BO;
- Above "FormWin programForm..." add:
BORegistry.DataAccessor = new DataAccessorInMemory();
- Run the solution and add items in the generated form. If you get errors, report this in the Forum.
That was the WinForms desktop version, let's now run the web app in a browser using Visual WebGui:
- Set MyProject.VWG as the startup project
- Open web.config in MyProject.VWG and set the "vendor" as "inmemory"
- Open Global.asax.cs in MyProject.VWG:
- Add at the top:
using Habanero.BO;
- After "habaneroApp.Startup()" add:
BORegistry.DataAccessor = new DataAccessorInMemory();
- Run the solution - you should get a similar working app in a web browser.
Converting to Use a Database
You'll now need to decide which database you want to use. You'll need to create
a database with a MyClass table, which has two properties. The MyClassID is the primary key
and will have a Guid type in Sql Server and CHAR(38) in MySQL. The MyProperty is either a
string or a varchar(255) or any length you like.
Let's change our app to use our DB:
- Get the DLLs for your database (eg MySQL.Data.dll) and dump them in the installed Firestarter executable directory.
- Restart Firestarter
- Go to the Generate Code screen
- Add a connection to your database (click ... at Database Config)
- Generate your solution again (overwrites some parts of the existing one)
- In your solution, update the DB settings in app.config and web.config (vendors are:
mysql,sqlserver,oracle,firebirdembedded,firebird,postgresql,sqlite,access)
- Remove the DataAccessor lines we added earlier.
- Add your database DLLs to the references in MyProject.Win and MyProject.VWG
- Run. Your data will now be preserved when you close the program.
What Now?
You can now do any of the following:
- Do the Full Tutorial
- Play with the TutorialProject or with this one
- Watch the Videos, which add some detail to the above
- Browse the Wiki to explore Habanero how-to's