On Dec 22, 2006, at 2:48 PM, [EMAIL PROTECTED] wrote:

> My primary goal is to express this relation on the GUI. I think I  
> understand the concept of bizobj. But haven't managed to figure out  
> where am I supposed to code the bizobjects relations. My  
> assumptions have been:
> - bizobjs are instantiated at the form level and used there
> - tried to relate the bizobject instances (for customer and orders)  
> without success. I've tried this in FrmCustomer.py but it's  
> obviously the wrong place.

        It's actually very simple, once you know what to do.

        First, you need to tell the Orders bizobj how it is related to its  
'parent'; in this case, Customer. The property you need is called  
'LinkField', so all you need to add to the initProperties code is:

self.LinkField = "cust_fk"

        This will link the Orders object to its parent via the PK of the  
parent, and the specified LinkField in the child.

        Now all that's left is to tell the parent that it has a child. The  
appwiz code is a little too terse for my taste, so this is what I  
would write in the form's afterInit() method:

        # Create the bizobjs
        bizCust = app.biz.CustomerBizobj(app.dbConnection)
        bizOrders = app.biz.OrdersBizobj(app.dbConnection)
        # Add them to the form. The first will automatically
        # be the form's PrimaryBizobj.
        self.addBizobj(bizCust)
        self.addBizobj(bizOrders)
        # This is how you relate bizobjs
        bizCust.addChild(bizOrders)

That's it! Now when you navigate to a record in Customer, the Orders  
bizobj will contain all the related Orders for that Customer.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to