AS Class Generator

The AS Class Generator generates ActionScript classes with or without offline metadata. Offline metadata is a part of the ColdFusion-AIR offline integration feature of ColdFusion 9. You can generate ActionScript classes either from a CFC or directly from a database table.

Install AS Class Generator

The AS Class Generator extension is installed with ColdFusion Builder, if you selected the Install Extension option when creating a server.

If you did not install the AS Class Generator extension when creating a server and want to install it now, use the AS Class Generator extension archive file (ASClassGenerator.zip). The AS Class Generator extension archive file comes packaged with ColdFusion Builder and is in the Extensions directory within the ColdFusion Builder installation. For more information on installing an extension, see Install and uninstall extensions.

Use AS Class Generator

The AS Class Generator application is available at the following levels:
  • RDS Dataview view

  • Project Navigator view

AS class generation is supported in the following scenarios:
  • From a database table

  • From a CFC

    You can generate the AS class from either an ORM CFC or a traditional CFC.

AS Class Generation from a database table

  1. In the ColdFusion Builder perspective, select RDS Dataview.

  2. If you have configured an RDS user name and password, specify the RDS user name and password.

    Note: You set the RDS password in the ColdFusion Administrator. Do not confuse the RDS password with the ColdFusion Administrator password, which is also managed through the ColdFusion Administrator.
  3. The list of data sources available in the configured server are listed.

  4. Select a data source.

  5. Right-click a table in the data source and select Generate AS Class from DB Table > Generate AS Class.

    Note: The Generate AS Class from DB Table option appears only if you right-click the table name. Clicking the data source or records within the data source does not show these options.
  6. Enter the following details in the Generate AS Class dialog box.
    • Specify or select a location to store the ActionScript class files.

    • Select the Include AS Metadata Tags check box to include the following metadata tags:
      [RemoteClass]
      Maps the ColdFusion CFC or Java objects on the ColdFusion server with the generated ActionScript class

      [Entity]
      Indicates that the generated ActionScript class has to be persisted to the AIR SQLite database as a table. This tag is a ColdFusion-AIR offline integration tag.

      [Id]
      Specifies the AS Class property as a primary key after the ActionScript class is persisted to the AIR SQLite database table.

    • Enter the path to the remote CFC class using dot notation relative to the web root. For example, if the path to the CFC is C:\ColdFusion9\wwwroot\CFProj\xyz.cfc, the dot notation path is CFProj.xyz

      Note: This entry is ignored if you have not selected the AS Metadata Tags check box.
    • Enter the name of the package. The naming convention is the same as the ActionScript naming convention.

  7. The ActionScript Class file is created with the naming convention databasetablename.as

Reviewing the generated ActionScript Class file

The following code is an example of an ActionScript class file - Employees.as that is generated from the Employees table in the cfdocexamples data source.

Code

Description

package package1

The package is created with the name “package1”

[RemoteClass(alias="cfproj.xyz")]

The ActionScript Class maps with cfproj/xyz.cfc on the server.

[Entity] public class EMPLOYEES { [Id] public var EMP_ID:int; public var FIRSTNAME:String; public var LASTNAME:String; public var EMAIL:String; public var PHONE:String; public var DEPARTMENT:String; public var LOCATION:String; public var IM_ID:String; public function EMPLOYEES() { } }

The class name is the same as the database table name. Each property in this class corresponds to a column in the Employees database table. The data type of each property is mapped automatically after introspecting the column data type.

AS Class Generation from CFC

From an ORM CFC

  1. Create an ORM CFC.
    Note: CFCs for which ActionScript classes are generated must be within the ColdFusion web root.
  2. In the Project Navigator, right-click the ORM CFC and select Generate AS Class from CFC > Generate AS Class.

  3. Enter the following details in the Generate AS Class dialog box.
    • Specify or select a location to store the ActionScript class files.

    • Enter the name of the package. The naming convention is the same as the ActionScript naming convention.

    • Select the Include AS Metadata tags check box to include the [RemoteClass]tag.

    • Select the Include CF-AIR Offline Metadata check box to include the following tags:
      • [Entity]

      • [Id]

    • If the ORM CFC already has the necessary information like, primary key and data type for each property, you need not enter the ColdFusion data source.

From a traditional CFC

  1. In the Navigator view, right-click the CFC and select Generate AS Class from CFC > Generate AS Class.

    Note: CFCs for which ActionScript classes are generated must be within the ColdFusion web root.
  2. Enter the following details in the Generate AS Class dialog box.
    • Specify or select a location to store the ActionScript class files.

    • Enter the name of the package. The naming convention is the same as the ActionScript naming convention.

    • Select the Include AS Metadata tags check box to include the [RemoteClass]tag.

    • Select the Include CF-AIR Offline Metadata check box to include the following tags:
      • [Entity]

      • [Id]

    • If the primary key and data type for each property is not specified in the CFC, enter the ColdFusion data source name.

Points to remember

  • For CF-AIR offline integration, column-specific metadata tag [Column] additions are not currently supported. However, you can manually add the column-specific metadata tags after the ActionScript class file is generated.

  • RDS does not provide information about the primary key of a table in the data source. Use the cfdbinfo tag to identify the primary key. The cfdbinfo tag does not support ODBC drivers including Microsoft Access. Hence, for unsupported data sources, you manually define the Id column in the generated ActionScript Class file.

  • CFCs for which ActionScript class files are generated must be within the ColdFusion web root.

  • In an ORM CFC, datatype/type is an optional attribute of the cfproperty tag. If this attribute is not present in the CFC, ActionScript class files are not generated. To ensure that the ActionScript class files are generated, specify the ColdFusion data source. Data type information is retrieved from the database table and the ActionScript class file is created.