On Dec 14, 2008, at 10:28 AM, Bob Sysero llc Dev wrote:
> I am working on number 2 and in the Class Designer my button Create
> Spread Sheet Object dCreateCalc:
> def onHit(self, evt):
> customerBizobj = self.Form.getBizobj("customer")
> customerBizobj.spreadSheetBizObj()
Please don't do it this way. It leads to all sorts of tangled code.
What if you want to add a menu item to do the same thing? How about a
tool bar action, or a right-click action? If you put all your logic in
the event handler of a particular button, you now have to find a way
to call that logic from all sorts of different places. Or copy/paste
that same logic into a bunch of different handlers, which is a
maintenance headache.
Have the button's onHit handler call a method in the form. You'll
thank me later.
> This works and I am able to call customerBizobj.spreadSheetBizObj()
> by placing a dabo.Trace() at the start of my spreadSheetBizObj()
> method.
> The problem is how to access the dataSet within the
> spreadSheetBizObj()
> method. I tried different ways with the simple error:
> custmerBizObj = self.getBizobj("Customer")
> AttributeError: 'CustomerBizobj' object has no attribute 'getBizobj'
Looks like 'self' in this context is already the bizobj. IOW, you
aren't in form code, but bizobj code. Forms get references to their
bizobj by calling their getBizobj() method.
> I just was looking at the code in my Object dCrateCalc and I might be
> able to get the dataSet and pass it into my
> customerBizobj.spreadSheetBizObj(dataSet).
> customerBizobj = self.Form.getBizobj("customer")
> customerDataSet =customerBizobj.getDataSet()
> customerBizobj.spreadSheetBizObj(customerDataSet)
I guess I'm not sure what you're trying to do in the last line. What
is 'spreadSheetBizobj'? Looking at the code later on in your message,
it seems that that is a bizobj method that creates the spreadsheet. Is
that correct? If so, I would suggest a more descriptive method name
such as 'createSpreadsheet()'. Also, you don't need to get the dataset
in one bizobj method and pass it to another method in the same bizobj;
that second method can just as easily call 'self.getDataSet()'.
-- Ed Leafe
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]