Class wwCollectionList

This class, subclasses from the wwBusiness class, is used to represent a list of objects as are commonly used in child objects in one to many relations. A typical example might be the lineitems of an invoice. This class uses an internal public aRows member to contain the actual data items of the child data which can be loaded with the LoadFromCursor() method which loads the array members from a cursor. Since this object is subclasses from wwBusiness you can use it to manage both the list as well as individual items in that list.

You can use this mechanism as the offline storage for things like lineitems on an invoice for example. To actually manipulate each item you can do something like this to use the 'full' business object to use the data:

*** cLineItems here is subclassed from wwCollectionList
*** and is bound to a line items table
oInvoice.oLineItems = oInvoice.CreateChildObject("cLineItems")
oInvoice.oLineItems.LoadFromCursor()

*** Retrieve the first item of the array and store it to the local oData member
oInvoice.oLineItems.oData  = oInvoice.oLineItems.Item(1)

*** Write it out
oInvoice.oLineItems.Save()

This would be using the default Save() method which saves an individual lineitem.

Alternately you can use the LoadFromCursor() and SaveToCursor() methods to simply load and save the list as a whole:

oInvoice.oLineItems = oInvoice.CreateChildObject("cLineItems")
oInvoice.oLineItems.LoadFromCursor()

*** Retrieve the first item of the array and store it to the local oData member
oInvoice.oLineItems.aRows[1].Description = "New Description 1"
oInvoice.oLineItems.aRows[2].Description = "New Description 2"

*** Now go write back all the lineitems
oInvoice.oLineItems.SaveToCursor()

The code for both of these type of operations probably should be wrapped into the cLineitems class internally for better design and then have methods such as LoadLineItems() and SaveLineItems() which encapsulate this behavior.

Parent Class: wwBusiness

Custom
  wwItemList

Class Members

MemberDescription

Add

Adds an item to the array manually. This should be an object either from a SCATTER NAME or from CREATEOBJECT("SomewwBusiness subclass").

o.Add(loItem)

Clear

Clears the entire object array and sets nCount to 0.

o.Clear()

Item

Retrieves an item by index count.

o.item(lnIndex)

LoadEmptyItemArray

Creates a single item array with the first item set to an empty item loaded from the oData member via wwBusiness::GetBlankRecord().

o.LoadEmptyItemArray(lcClass)

LoadFromCursor

Loads the oRows collection with the contents of the active cursor. The active cursor should reflect the business object you are loading into.

o.loadfromcursor(lcBusObjectClass)

SaveToCursor

Saves each of the items in the array to disk using individual item Save() calls. Loads the oData member for each operation then performs a .Save() for each if the object is a business object.

o.SaveToCursor(llCollectionHoldsClass, llUseTransaction)

nCount

Number of items in the list.

oRows

A collection of row objects that contains one object for each element. Each object is created with SCATTER NAME from the LoadFromCursor() method.

Requirements

Assembly: wwBusiness.vcx

© West Wind Technologies, 1996-2018 • Updated: 11/09/18
Comment or report problem with topic