Information générale
Catégorie:
The Mere Mortals Framework
Titre:
CBizObjForm.DisplayBrokenRules only checks primary bizobj
Kevin,
Your DisplayBrokenRules method only checks the primary business object for broken rules. I have fixed it by creating a new method, FindBrokenRule which contains the search code and changed the methods as follows:
<\pre
PROCEDURE displaybrokenrules
*---------------------- Location Section ------------------------
* Library: CForms.vcx
* Class: CBizObjForm
* Method: DisplayBrokenRules()
*----------------------- Usage Section --------------------------
*) Description:
*) Passes the call to the broken rules message object.
*) If a message object is not instantiated, it creates one
* Scope: Public
* Parameters:
* 1. toBizObj - Business object for which broken rules
* are displayed.
*$ Usage:
*$
* Returns: Logical .T. by default
*--------------------- Maintenance Section ----------------------
* Change Log:
* CREATED 09/28/99 - KJM
* MODIFIED
******************************************************************
LPARAMETERS toBizObj
LOCAL ;
loBizObj
loBizObj = This.FindBrokenRule(toBizObj)
IF ISNULL(loBizObj)
RETURN
ENDIF
IF This.CreateBrokenRulesMsgObject()
*---------------------------------------------
*--- Call the broken rules message object with
*--- a reference to the business object
*---------------------------------------------
This.oBizRulesMsg.Show(loBizObj)
ENDIF
ENDPROC
*-- Searches related business objects for broken rules
PROCEDURE findbrokenrule
* Program....: CBizObjForm.FindBrokenRule
* Version....: 1.0
* Author.....: Rex L. Mahel
* Date.......: November 24, 1999
* Compiler...: Visual FoxPro 06.00.8492.00 for Windows
* Abstract...:
* Changes....:
LPARAMETER toBizObj
LOCAL ;
loRetObj,;
lnRulesCount,;
lnObjCount,;
lnCount,;
loChildBizObj
IF VARTYPE(toBizObj) != 'O'
IF ! VARTYPE(ThisForm.oBizObj) == 'O'
RETURN .NULL.
ENDIF
toBizObj = ThisForm.oBizObj
ENDIF
loRetObj = .NULL.
IF ! VARTYPE(toBizObj.oBizRules) == 'O'
RETURN loRetObj
ENDIF
lnRulesCount = toBizObj.oBizRules.GetCount()
IF lnRulesCount # 0
RETURN toBizObj
ENDIF
*---------------------------------------------------------
*--- If no rules are broken, check child business objects
*---------------------------------------------------------
lnObjCount = toBizObj.RefBizObj.GetObjectCount()
FOR lnCount = 1 to lnObjCount
loChildBizObj = toBizObj.RefBizObj.Get(lnCount)
loRetObj = ThisForm.FindBrokenRule(loChildBizObj)
IF ! ISNULL(loRetObj)
EXIT
ENDIF
ENDFOR
RETURN loRetObj
ENDPROC
The only potential problem I see is if you have a complex situation where business objects are related, you could get a recursion error in the FindBrokenRule method
Thanks
Rex
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement