StrataFrame Forum

Browse Dialog

http://forum.strataframe.net/Topic9241.aspx

By Sarosh - 6/1/2007

Hi!

I would like to have only one BrowseDialog for all my BO's on my form so my question is how do I set the the BD's properties in code?

i.e. in the click event for the browse button of the form I would like to do something like:

if (this.ActiveBO is CustomerBO)

{

   this.browseDialog.SomeProperty = "CustomerSomeValue"

   this.browseDialog.SomeOtherProperty = "CustomerSomeOtherValue"

   etc.

}

else if (this.ActiveBO is OrderBO)

{

   this.browseDialog.SomeProperty = "OrderSomeValue"

   this.browseDialog.SomeOtherProperty = "OrderSomeOtherValue"

   etc.

}

Is this the right way or is their an easier/cleaner way to do this

Sarosh

By Trent L. Taylor - 6/1/2007

If you create a BrowseDialog and look at the code that is created within the designer, you will see that there are a lot of properties and collections that get set.  Making one BD handle all of your BOs really is not a feasible prospect and even I would not attempt to do that as it would be a lot of code overhead.  You are better off creating a BD for each of your BOs and then dynamically swapping which BD is used.  ALso, if you class these then you can reuse them on other forms as well and the will be encapsulated, which is extremely important, otherwise you are going to end up rewriting code over and over again.
By Sarosh - 6/1/2007

Hi!

Ok I get your point.

How can I set all the BD properties of a BD in the forms designer and then save that BD as a class so that I can reuse it in different forms?

Is it possible to specify in the BusinessObjectMapper what class to inherit from instead of the default "

MicroFour.StrataFrame.Business.BusinessLayer"? The reason I ask this is that I would like to have a company/application level BO class between "

MicroFour.StrataFrame.Business.BusinessLayer" and lets say the CustomerBO

Sarosh

By Trent L. Taylor - 6/1/2007

Well at this point it is all about inheritance and reusability.  You cannot make a BD totally generic, the core of a BD is the type of BO that is assigned to the control.  If you try type the BO as a BusinessLayer and then expect the SearchFields, etc. to work, it won't.  All subsequent properties touch the type of the BO that is assigned to the BrowseDialog.  You can see a sample of classes a BD in the CRM Sample Application.  We take a somewhat different approach in our medical system since we have a code field that goes along with the browse.  All of our BrowseDialogs reside on a user control which encapsulates the BO that is used and then uses the BOTranslations of the user control to expose the settings to the form on which the control which houses the BD is dropped.
By Sarosh - 6/1/2007

Hi!

Maybe I was not clear. I had two different questions

1] How can I save a BrowseDialog control after setting all its required properties lets say for a CustomerBO in the form designer into a class by itself so that I can reuse it in all forms that have that CustomerBO.

Now a question on a seperate topic.

2] How can I create a Business Object (using the Business Object Mapper) e.g. CustomerBO that inherits from my own base Class and not the default MicroFour.StrataFrame.Business.BusinessLayer class.

e.g.

I would like the Code generated by the Business Object Mapper to be changed from:

public partial class CustomerBO : MicroFour.StrataFrame.Business.BusinessLayer

to this:

public partial class CustomerBO : MyCompany.BaseBO

where MyCompany.BaseBO inherits from MicroFour.StrataFrame.Business.BusinessLayer

basically have my own BO class between MicroFour.StrataFrame.Business.BusinessLayer and CustomerBO but generated by the Business Object Mapper.

Thanks

Sarosh 

By Fabian R Silva, - - 10/9/2007

Trent L. Taylor (06/01/2007)

All of our BrowseDialogs reside on a user control which encapsulates the BO that is used and then uses the BOTranslations of the user control to expose the settings to the form on which the control which houses the BD is dropped.




Can I create a class that receive parameters for columns, search fields, etc and dinamically create the browsedialog at runtime? or I have to create 1 BD for each BO? I not understand if in your medical software you create 1 user control for each BO or 1 user control that you drop on a form and it work for any BO



Basically, I like to dinamically allow a user to select wich fields and columns like in the browse, then assign it to the BD class and show it; How do you think that is best to accomplish it? thanks in advance Smile
By Trent L. Taylor - 10/9/2007

The BrowseDialog is, like all other SF classes, a class with collections.  So in essence you could create a BD dynamically in code.  This would require some effort on your part.

One thing that you misunderstood is that we have one BD that is used for many different BO types.  This is not the case.  We create a unique BD for each BO type that we plan to have a browse for in our application.  We create a user control for each BD, and drop the BD on the SF user control.  This allows us to set it up as we would like easily without manually coding it.  When can then drop it on any SF form and the use the BOTranslations property of the User Control to use a BO.

Even in our medical application, we use a unique BD for each unique BO type.

By Fabian R Silva, - - 10/9/2007

I will try to make a unique BD for all the project (my boss request w00t ) and if I can't I try to convince him to use you aproach of 1 BD for each BO Smile thanks!