Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bizrules
Message
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Title:
Miscellaneous
Thread ID:
00599033
Message ID:
00599201
Views:
9
>>I thought about doing that, but if the data is not saved, creating a new instance won't work. The problem is further complicated when moving to COM. How do I enusre that the current instance is used for the bizobjs?
>
> You could scatter the data out to an object then pass this data down through to the child object that requires it. If you need data from more than one object for validation to occur, you can use a "parameter" object (see the Wiki for info on this). I created one that I use a LOT for my web applications. It automatically adds new properties on the fly when you set any values, and returns an empty string if the property doesn't exist. I pass this object around whenever I need to do validation.
>
>In COM, if you're not using an event object, you'll create each object and manually set the child object references. You can use these references to pass the same data back for validation.

Hmm...Maybe add a method called ScatterData() to your business objects that looks something like:
(NOTE: Untested code! This probably won't work as is)

FUNCTION ScatterData
LPARAMETERS toParameter
LOCAL loSelect, ;
loParameter, ;
lnCount, ;
lnIndex, ;
loChild

IF VARTYPE(toParameter) = "O"
loParameter = toParameter
ELSE
loParameter = CreateObject("ParameterObject")
ENDIF

loSelect = CreateObject("CSelect", This.SetAlias())

SCATTER NAME loParameter

lnCount = This.RefBizObj.GetObjectCount()

FOR lnIndex = 1 TO lnCount
loChild = This.RefBizObj.aChildren[lnIndex, CHILD_OBJECT)
loChild.ScatterData(@loParameter)
ENDFOR

RETURN loParameter
ENDFUNC

Then, anytime you needed more data to do validation you could just call this method and get a populated object with all the info. Of course, you'll have to deal with overlapping field names somehow. Maybe just scatter to an object then add this object to the parameter object using the property name of the main alias for that bizobj?
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform