Using the wwBusiness Object Wizard

To facilitate the process of creating specific subclasses for your business objects Web Connection provides the Business Object Wizard which connects a table to a business object. Note that although a table is the most common scenario, tables are not required for the business object.

To start the Wizard do:

DO Console WITH "BUSOBJECT"

*** For Client Tools
* DO wwclient_Console with "BUSOBJECT"

which brings up the Wizard form:

Base Class
You can specify a base class for the new class that is to be created. By default this will be wwBusinessObject in wwBusinessObject.prg and that's the recommended base class. You can also use wwBusiness.vcs and wwBusiness or choose any base class you subclassed yourself (an application base business object.)

Name of the class
Pretty obvious - this will become the business object class name.

Class library
Where to store the new business object. This can either be a PRG files for subclassing from wwBusinessObject or a VCX class when subclassing from wwBusiness.

Base Table
The Web Connection business objects tend to link to tables - so pick a table that you want as your base table. You may not actually use the table later on but you need to specify one here. If you're using SQL Server data only just type in the name of the file, otherwise go ahead and pick the file. For Fox tables I suggest that you use relative paths such as .\wwstore\wws_items.dbf instead of fully hardcoded paths. Relative paths port much easier if you move the application. For Sql Server you should specify just the table name.

ID Table
For Fox data only you can specify the name of the ID table. If the table doesn't exist one will be created. For SQL Server the table name always will be wws_id and it will be created if it doesn't exist. The Wizard will add a record to this table with the name of the base table.

PK Field
Specify the field that will be used as the primary key field. Remember this field must be a numeric (Integer preferrably) field in order to be able to accept the PK generation features. If you choose a different type you'll have to override the NewId() method to handle the ID generation.

For Fox data you can specify a field name here and the Wizard will add that field to the ID table. For SQL data you have to manually add the field to the table.

Fox/SQL Data options
Choose whether you want to work with Fox or SQL Server data or both. This option controls the ID table updates.

CreateTable() and Reindex() generation
If these options are checked these methods are automatically generated for you based on the structure of the table that the business object is bound to. Note, this will overwrite any code in those methods and generates code only for the Fox tables, not SQL Server tables (nDataMode=0). If you have custom code here you can use the Table and Index Structure Exporter utility and paste the generation code manually.

SQL Connection
If you want to use SQL Server provide a connection string that will allow you to connect to the SQL database you want to connect to. This value will also become the default connection string used by the object (which you can of course override with code at any time).

Note that connection strings default to server=.;integrated security=yes; and you can optionally omit those values unless you want to use something different. To connect to a DB named WebStore on the local server with integrated security it's enough to specify: database=webstore.

Generate Class
Determines whether a class is generated. You can turn this off if all you want to do is generate the ID table entry.

Generate ID Table Entry
Determines whether the ID table is created and/or updated. The value of the counter is set to the highest PK + 1.

Note that you can run the Wizard multiple times without worrying about overwriting code. The Wizard only writes property values so existing class code is not affected. The exception to this are the CreateTable() and Reindex() options which will overwrite the respective method code with newly generated code.

A typical multiple use scenerio will be:

  • Create object for fox data
  • Come back to create SQL entries - run only the ID generation
  • Come back to update the ID table entry
  • Come back to update the CreateTable() and Reindex() methods when structure changes occur.

The Wizard remembers your last settings with a config stored in your temp directory.


© West Wind Technologies, 1996-2019 • Updated: 02/12/19
Comment or report problem with topic