Scaffolds: Adding Scaffolds
To add a scaffold:
- Add a table to your database. At present, it (and any tables it uses in relationships) may only have one column acting as a primary key. For the sake of example, we'll pretend we've added a table named "Contact"
- If the table is related to other tables in a one-to-many or many-to-many manner, add those relationships to your ORM configuration. Installing an ORM in ModelGlue Reactor's documentation. Transfer's documentation.
- When you use the Coldfusion 9 implementation of Hibernate ORM, you have to configure Model-Glue by adding the following to Coldspring.xml:
<alias alias="ormAdapter" name="ormAdapter.cfORM" /> <alias alias="ormService" name="ormService.cfORM" />
- Add the following tag to your ModelGlue.xml:
<scaffold object="contact" />
By default, this will create the following event handlers:
- Contact.List - Lists all contacts from the contact table
- Contact.View - Displays a specific contact in a read-only manner
- Contact.Edit - Provides a form to edit a contact
- Contact.Commit - Saves a contact to the database
- Contact.Delete - Deletes a given contact
Using the (optional) EVENT-TYPE attribute
For a given scaffold tag, you may specify the list of event-types to apply to each event-handler tag created by the scaffold tag. This is especially useful for applying functionality such as security automatically to your generated event handlers.
<scaffold object="contact" type="list,view" event-type="Admin,Sidebar,MainTemplate" />
Results in two event-handler's with their main tag like those below:
<event-handler name="contact.list" type="Admin,Sidebar,MainTemplate" /> <event-handler name="contact.view" type="Admin,Sidebar,MainTemplate" />
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)