com.sebtools Build 12 Documentation: Getting Started

Getting Started

Initializing

Manager.cfc is instantiated using the "init" method, which takes the following arguments:

Any other arguments passed to "init" will be automatically copied into variables scope. Any other components passed into "init" will also be copied into "This" scope.

Important Note: If you are running on a version of ColdFusion prior to ColdFusion 8, you will need to have Rick Root's excellent Image CFC installed to be called from "com.opensourcecf".

Loading Meta Data

In order to be useful, Manager must also be loaded with meta data definitions. This is done using the "loadXml" method (and optionally this "setField" method).

Here is a complete example from a very basic security application:

<tables>
	<table name="secUsers" labelField="FullName" sortfield="LastName" labelSingular="Admin" labelPlural="Admins">
		<field name="UserID" type="pk:integer" />
		<field name="username" type="text" label="User Name" Length="50" />
		<field name="password" type="password" label="Password" Length="25" />
		<field name="FirstName" type="text" label="First Name" Length="50" />
		<field name="LastName" type="text" label="Last Name" Length="50" />
		<field name="Email" type="email" Length="75" />
		<field name="LastLogin" type="date" />
		<field name="DateCreated"  type="CreationDate" />
		<field name="isUniversal" type="boolean" Default="0" />
		<field name="FullName" label="Name">
			<relation type="concat" fields="FirstName,LastName" delimiter=" " />
		</field>
		<field name="LastNameFirst" label="Name">
			<relation type="concat" fields="LastName,FirstName" delimiter=", " />
		</field>
		<field name="Permissions">
			<relation table="secPermissions" type="list" field="PermissionID" join-table="secUsers2Permissions" onDelete="Cascade" />
		</field>
		<field name="PermissionNames">
			<relation table="secPermissions" type="list" field="PermissionName" join-table="secUsers2Permissions" join-field="PermissionID" onDelete="Cascade" />
		</field>
	</table>
	<table name="secPermissions">
		<field name="PermissionID" type="pk:integer" />
		<field name="PermissionName" type="text" />
	</table>
	<table name="secUsers2Permissions">
		<field name="UserID" type="pk:integer" />
		<field name="PermissionID" type="pk:integer" />
	</table>
	<data table="secUsers">
		<row username="admin" password="admin" />
	</data>
</tables>

Note that each "table" element should have a "labelField", "labelSingular", and "labelPlural" attribute (though Manager will do its best if those are not provided). The "relation" element is direct map to DataMgr Relation Fields. The table and field elements have their own documentation pages.