StrataFrame Forum

Non Form Bound Business Object

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

By Larry Caylor - 4/19/2006

In order to provide role based security to my application I’m considering creating my own business objects that implement IIdentity and IPrincipal. I could create these outside of the framework but I would like to access my security DB through the Strataframe data access layer, especially since there was some mention in a previous post of future plans to implement an application server to handle that layer. What's the best approach to take when you want to create a BO that can use the DAL but won't be bound to a form?  I don't need the IContainerInterface but I do need to pass parameters to the constructor. Any guidance would be appreciated.

 

-Larry

By Gary C Wynne - 4/20/2006

Hi Larry

All you need to do is create your business object in the usual way, implement the interfaces you require and add your own custom constructor that accepts whatever parameter(s) you want to pass.

Then, where ever you require the BO, just simply construct the object instance as follows:-

PrincipalBO _bizSecurity = new PrincipalBO(object whateverParameter);

I hope I haven't seriously missed the point here Smile

Best

-=Gary

By Trent L. Taylor - 4/20/2006

Larry,

Gary's explanation sounds good.  Business objects can be instatiated and used in code just as easily as when dropped on a form.  This allows you to do basically anything you need to do with the BO itself.  Including inherited the BO to create another class, implementing interfaces, or adding a new constructor to the BO.

There is one thing you may want to keep in mind.  If you plan on using this BO on forms, you will want to make sure that your BO will still instantiate properly using the default constructors.  These are the constructors that are useed when a BO is dropped on a form.  Otherwise, add the interfaces and go to town Smile

By Larry Caylor - 4/20/2006

Gary & Trent,

Thanks for the input. In my mind I was making things more complicated then they really were. However in trying to implement my objects I've run into some other issues that you may have some suggestions for. Since I'm creating an object that implements an interface I don't want to expose the data base fields. Unfortunately Business Object Mapper doesn’t have an option set the scope of a field/property.  I can also imagine a situation where I would want a field to be Read Only. I could accomplish either using the custom code feature but I just found out that the Custom Code window doesn’t support cut-and-paste. Having to type all the code is a pain.

-Larry

By Trent L. Taylor - 4/20/2006

Larry,

The custom code window does support cut-and-paste.  This is how I create all of my custom code properties.  Do you have the "Custom Code" check box selected?  There must be something going on here because you are right, it would be painful to type this in.

Generally we wil let the BO Mapper create the field normally, open the designer file and make changes to the property until we have it the way that we like, then copy the copy from for the field from the designer file into the custom code area of the BO mapper.

Try again and let me know a few more details.  Thanks.

By Larry Caylor - 4/20/2006

Trent,

I'm using the 4/6/2006 pre-release version of the framework. In object mapper when you right click on the custom code window it does not bring up a pop-up menu to allow you to select paste. However Ctrl+V does work and the code gets pasted into the window.

I've also experienced problems with Visual Stuido when clicking OK on the Custom Field Properties window. VS crashes and asks to send a message to Microsoft. Apparently there is a hot fix available that may address this problem (MS Article ID: 915038). Have you guys experienced this problem or applied the hot fix?

-Larry

By Trent L. Taylor - 4/20/2006

You are correct that there is no context menu.  But the Ctrl+V works.  As for the crash, this is the first that I have heard about this.  I will look at the article you provided and see if there is something we can do to be pre-emptive.  Thanks.