On Wed, Nov 18, 2009 at 2:24 PM, Ed Leafe <[email protected]> wrote:
> On Nov 16, 2009, at 12:19 PM, Miguel Lopes wrote:
>
>> Yes Ed. There's one bizobj for both the parent and child tables.
>
>        Sorry, but your sentence is not clear (I realize English is not your
> native language). Can you tell me which is your situation:
>
> a) one bizobj to handle parent and child together
> b) one bizobj for the parent, and another bizobj for the child.
>
>        Option b) is the recommended approach in Dabo.

Sorry for not being clear. Yes. I have one bizobj for the parent and
another for the child table.

>
>> But there I still haev two probelms:
>> 1. I may or may not have one or more children. So automatic child
>> creation should not be used.
>
>        There is a hook method in the bizobj for code that you want to run
> when a new record is created: the dBizobj.onNew() method will be
> called when a new record is added. You can put code there to do
> whatever needs to be done.

I have a feeling this is what I'm looking for! I suppose in this hook
I can create child records, but I would like to be able to rollback
all changes if saving any of them fails (be it parent or child). Can I
cancel the save during dBizobj.onNew()?

>> 2. Which approach to choose for passing the child information
>> (potentially more than one child). Should I go with this idea of
>> assigning a bizobj attribute?
>
>        It really depends on how complex that information is, but in general,
> I prefer to put the logic so that it doesn't have to be passed around
> too much.

I rather have all the logic in one place as well (that's sound
design). In my case the user selects zero, one or more child records
in a pick list, then saves. Somehow I have to pass that dataset of
selected children to the code creating the parent and he children.
That's how I though of assigning the selected children dataset to an
atribute of the parent bizobj (the parent would set the attribute back
to None upon success or failure). Do you see a better way of
accomplishing this?

Miguel
_______________________________________________
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]

Reply via email to