Newb object design question....

Newb object design question....

Old forum URL: forums.lhotka.net/forums/t/5540.aspx


reagan123 posted on Monday, October 06, 2008

Hello...
Currently I have an application that captures data to fill out some forms.  I need the ability to auto populate the form with auto generated values in certain cases.  Currently the UI just gets a new object and hard codes values into it which I believe is a mistake.

Would it be correct to put a method on my business object that handles these auto generated write-ups?

Thanks for any input.

tmg4340 replied on Monday, October 06, 2008

Typically, this kind of thing is handled within the DP_Create method.  You put your defaults there, and then the object that's returned from the DataPortal is appropriately initialized, and picked up when your BO is bound to your form.  Plus, you can call the database to get your defaults if you need them.

HTH

- Scott

reagan123 replied on Monday, October 06, 2008

I thought about the DP_Create but wasn't sure how to tell when to do the writeup and when not to...

For example... One of the fields is "Remarks".  If it is a new object that is not being automatically generated remarks needs to be empty.  If it's a generated one it needs to say "Computer Generated Writeup".

Would this still be done in the DP_Fetch?

tmg4340 replied on Monday, October 06, 2008

How you manage the auto-generation depends on how you determine when it needs to be done, but I think the easiest method is to define a criteria class to pass into DP_Create that would contain the necessary information.  If you need to go to the database, you can certainly do that in DP_Create, just like you would in DP_Fetch - in fact, that's part of the original intent of DP_Create.

HTH

- Scott

ajj3085 replied on Tuesday, October 07, 2008

If you're generating a new form, but still using some pre-populated values, then you'd have a second overload of your create factory method that takes a criteria object.. the criteria will contain the data to pre-populate.

Copyright (c) Marimer LLC