The wwBusiness object provides the core business object class. This class is a single level business object class that implements both the business and data tier in a single object to provide ease of use and maximum performance. The base object provides core data access functionality (Load, Save, Query, New etc.) through its base class methods. Query based data access is also supported through native Fox syntax or using the class methods which can route to the appropriate backend. Fox or SQL Server are natively supported. SQL Server is supported with SQL Passthrough commands. The object also supports remote data access over the Web against a SQL Server backend (with some limitations a Fox backend can be used as well).
Data representation of the class is handled through an oData member which contains the class 'data'. Each object is individually loaded except for queries which can return data in variety of formats such as cursors, XML or ADO. The oData member deals with class instance data (record level operations) and is completely disconnected from the database while in the class. Load() and Save() are the two transfer methods that handle moving data to and from the database.
This object framework is uniquely geared towards offline operation which is ideal for Web operations and passing data around the Web. In HTML based Web applications the object's oData member is extremely useful for databinding to HTML templates and reading data back in bulk using Request.FormVarsToObject(). The object's disconnected data model also makes it uniquely qualified for object aggregation by combining multiple objects into an object hierarchy.For example an oInvoice object contains oCustomer and oLineItems which are accessible through the single oInvoice object reference. Because of the self-contained nature of objects, it's easy to persist data to and from XML and pass them around the Web as well as making it very easy to use the business objects in HTML templates where data is bound to the object properties (<<code>><%= oInvoice.oCustomer.oData.LastName %><</code>>). Web Connection's object centric approach also allows you to pull in data back into the object from forms using Request.FormVarsToObject resulting in very little code written to transfer data to and from HTML pages.
Beause the framework consists only of a minimal set of methods on this object it's easy to get started with it. Because of the single level implementation the framework is also very efficient. In addition a Wizard is provided to help you create business objects by mapping to tables.
Required Support Classes
wwUtils.prg
wwSQL.vcx (only if you use nDataMode = 2)
wwEval.prg
CodeblockClass.prg
wwHTTPSQL.prg (only if you use nDataMode = 4)
wwXMLState.prg (only if you use Get/SetProperty methods)
wwCollections.prg
Custom
wwBusiness
| Member | Description | |
|---|---|---|
![]() |
AddValidationError | Adds a validation error to the oValidationErrors collection. Pass an error string and optional object name. o.AddValidationError(lcMessage,lcObjectName) |
![]() |
Backup | Takes the full content of the table and backs it up into the specified directory. o.Backup(lcPath,llCreatePath) |
![]() |
close | Closes the currently open master table or releases the SQL connection. o.close() |
![]() |
convertdata | Converts data from a cursor or the current object into the requested resultmode. o.convertdata(lnResultMode, lcDocRoot, lcTable, lcRow) |
![]() |
createchildobject | Creates a child object instance that inherits the properties from the current object appropriate from the current object instance. o.createchildobject(lcClass) |
![]() |
createnewid | Creates a new Primary Key ID number for the table using an ID table. o.createnewid() |
![]() |
createtable | Create the primary table for this object. This method should always be subclassed and implemented by the developer. o.createtable(lcFileName) |
![]() |
delete | Deletes the specified record from the underlying table. If no PK is passed the current PK of the loaded object is used. o.delete(lnPk) |
![]() |
execute | Executes a fully qualified raw SQL statement through the class. Can be used for any backend data command using either VFP syntax or SQLExec() style SQL commands. o.execute(lcSQL) |
![]() |
find | Tries to find a record based on a filter string and sets the oData member. Only the first item found is returned so you probably want to reserve this for known lookups of unique items. o.find(lcFilter) |
![]() |
getblankrecord | Retrieves an empty record and creates an empty oData member. Note no defaults are set. o.getblankrecord() |
![]() |
getproperty | Retrieves a property out of the XML field. Properties can be written with SetProperty. o.getproperty(lcProperty) |
![]() |
importdata | Imports data using the same o.importdata(lnMode,lcData,lcAlias) |
![]() |
load | Loads the oData member with a record accessed by PK. This method or a specialized version of it should be used to work with record level objects. o.load(lnpk) |
![]() |
loadfromxml | Imports object data from an XML string or XMLDOM object. o.loadfromxml(lvXML,lnMode) |
![]() |
new | Creates a new oData member. Creates a PK value and sets any defaults coded in the New method. o.new() |
![]() |
open | Opens the data source or remote connection. For ODBC commands the oSQL member holds the SQL connection. o.open(lcFile, lcAlias, llForceReconnect) |
![]() |
query | High level query method that is aware of the data mode in operation. For porting data between different data layers use this method for SQL commands that can run against any backend. o.query(lcSelect, lcCursor, lnResultmode) |
![]() |
reindex | Used to PACK and Reindex the data files. o.reindex(llSaveIndexString) |
![]() |
save | Saves the current data member in oData to the underlying table. o.save() |
![]() |
seterror | Sets the error flag and error message properties. o.seterror(lcErrorMsg, lnError) |
![]() |
setproperty | Sets a property value in the XML field. Note: for performance reasons no checks are performed if the XML field exists. o.setproperty(lcProperty, lvValue) |
![]() |
setsqlobject | Assigns existing SQL object to the oSQL object or creates one if a connection string is passed. Handles updating data mode and other admin tasks. o.setsqlobject(loSQL) |
![]() |
sqlbuildinsertstatement | Builds a SQL string to perform insert operations from the oData member to the database (used for Remote data only). o.sqlbuildinsertstatement(loData) |
![]() |
sqlbuildupdatestatement | Builds a SQL UPDATE statement from the current oData member (used for remote data only). o.sqlbuildupdatestatement(loData, lcSkipFields) |
![]() |
statusmessage | Displays status information. Use this method to have the business object communicate with whatever output mechanism required. Default is a WAIT WINDOW... o.statusmessage(lcMessage) |
![]() |
updatestructure | Update the structure of the file based on the CreateTable method's structure. o.updatestructure() |
![]() |
validate | Virtual method that can be used to hook up validation logic. No implementation in the base class.This method typically contains code that checks the content of the oData member. o.validate() |
![]() |
calias | The Alias of the master file. |
![]() |
cconnectstring | SQL ConnectString if DataMode=2 |
![]() |
cdatapath | Location of the data |
![]() |
cerrormsg | Any error messages that occurred. |
![]() |
cfilename | Filename of the master file of this business object. |
![]() |
cidtable | Table used to generate new PK Ids. |
![]() |
cpkfield | The field used as the primary key in the table. This field must be an integer or numeric field. |
![]() |
cresultxml | Methods returning XML will return the XML in this property. |
![]() |
cServerUrl | A URL on the server that's running the wwHTTPSQLServer component to process client requests. |
![]() |
cskipfieldsforupdates | Property that holds fields that are skipped for Insert and Update statements built on the fly. Use this if you pull extra fields that aren't part of the base cursor used in Save operations. |
![]() |
csql | SQL String for a query |
![]() |
csqlcursor | Requests that return a Fox cursor will use this name for the cursor name. |
![]() |
lCompareUpdates | Will send updates by only updating fields that have changed. |
![]() |
lerror | Error flag for the previous operation. Note this property must be managed by the developer for custom methods. |
![]() |
lValidateOnSave | Determines whether Save() automatically calls Validate(). |
![]() |
ndatamode | Data access mode for the business object. 0 - Fox Data native, 2 - ODBC (SQL Server) |
![]() |
nresultmode | Determines how data requests are returned. 0 - VFP Cursor, 2 - XML, 4 - ADO rs |
![]() |
nupdatemode | Determines whether the data member is in edit or new mode. 1-edit mode, 2 - New |
![]() |
odata | Data member that receives all of the field names as property values. |
![]() |
oHTTPSQL | An instance member for an wwHTTPSQL class that handles data access over the Web when nDataMode is set to 4. |
![]() |
osql | An instance of a wwSQL object that handles data connection if nDatamode = 2. All SQL commands run through this object for remote data. |
![]() |
oValidationErrors | A wwCollection of wwValidationError objects. |
![]() |
oValidationErrors | A collection of Validation Errors that let you indicate errors that occured during calls to the Validate() method or otherwise. |
![]() |
vresult | Variable result property. Used at this point only for ADO recordsets returned as a result from queries. |