Subcalssing SF Business Objects


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I want to start subclassing SF Buisness Objects (so I can imbed ny own Code in some of the methods)  and am not sure how to do this. I have successfully subclassed a few controls (TextBoxes, Lables) etc and they are working fine, so I am using a similar approcah for Buisness Objects.

I tried :  

public class KernelBO : MicroFour.StrataFrame.Business.BusinessLayer
{
}
My project compiles ok. I then created a new Business Object in the normal way , and went in manually and changed the generated code

from:
public partial class SquBO : MicroFour.StrataFrame.Business.BusinessLayer
to:
public partial class SquBO : KernelBaseSF.KernelBO


but got an error in compiling the Business Objects Project (KernelBaseSF.KernelBO does not contain a constructor that takes 2 arguments

What am I doing wrong here ?

 


Sam Tenney
Sam Tenney
StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)StrataFrame Novice (102 reputation)
Group: StrataFrame Users
Posts: 70, Visits: 3.5K
Hi Gerard,

There used to be an article available from this website named "Subclassing Business Objects" written by Les Pinter, but I cannot find it now.  It might help you if somebody can find it.

I wish I could help you directly, but I am still a novice.  I only remember that the procedure was not at all what I expected.  I'm sure somebody from StrataFrame will help you soon.

Sam Tenney
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I have a copy if you want me to email it too you?
Terry Bottorff
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Terry.

Yes, Please email it.

Not sure if its the same one as an article on the LesPinter.com about Subclassing in general. I found that helpful for subclassing the standard controls, and there is also a section in there about subclassing BusinessObjects. I started reading it, but it seemd to be extremely complicated and went on to a few pages.... I was expecting it to take one or two lines to subclass.. but perhaps I am wrong , so I decided to post here in the hope that there is a simple way of subclassing Business Objects .... I presume most people subclass BUisness Objects as it is supposed to be best practise.
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
That is exactly the one it is. So no need to send it.
Sorry.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Terry

I have had another look at the artcile and it seems to concentrate on Subclassing a specific BuisnessObject that was created in an application.

All I want to do is subclass the StrataFrame BusinesObject Class so I can insert my own specific code wherever required

Perhaps someone from SF might jump in
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
The error you are getting is likely because your base class and derived class don't have matching constructors.  I.e. the following will bomb:

public class BaseBusinessLayer : MicroFour.StrataFrame.Business.BusinessLayer
{
    //-- Default, no argument constructor inferred
}

public class DerivedBO : BaseBusinessLayer
{
    //-- Oops, what constructor of base class is to be called here?
    //    There is no constructor in BaseBusinessLayer with two constructors.
    public DerivedBO (int index, int companyID) {}
}


All you need to do is explicitly call the correct constructor of the base class:

public class DerivedBO : BaseBusinessLayer
{
    //-- Explicitly call desired constructor of base class.
    public DerivedBO (int index, int companyID)
        : BaseBusinessLayer()
    {}
}


Also, BusinessLayer (and sub-classes of it) isn't really meant to be directly instantiated. They define an interface for common data and functionality for actual BOs (i.e. BOs built via the BO mapper).  There are lots of methods/properties that will through NotImplemented exceptions if just left as-is.
Edited 13 Years Ago by Greg McGuffey
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Greg.

If subclassing the SF Business Objects is not the way to go, I'm wondering whats the best way of inserting my own functionality into the SF Business Objects.

For instance, I will now have code that I want to insert in the SetDefaultValues event of a Buisness Object (following on from another thread) . I would see this going into most of my Business Objects.The code that will run will take data from another BUsiness Object and insert DataDriven values into the Business Object

So what I want to do, is Subclass the Business Object (SF One) and add in code to the SetDefaultValues event.

I could call the code from every Business Object I create,  but was looking for a more OO way of doing it
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
You're headed in the right direction.   You DO want to sub class BusinessLayer, then inherit you BOs from this. 

My comments were probably a bit confusing, as in my mind, I have classes that inherit from BusinessLayer and are intended to extend the base functionality (like you want to do with your set default values code) and then there are BOs which also inherit from BusinessLayer (or a sub class of BusinessLayer), but they are then built with the BO mapper.  However, they are all sub-classes of BusinessLayer. 

If you look in the designer file of a BO, you'll see ALL the other stuff you have to do to get a working BO. So, there is kind of this division between BusinessLayer, providing base functionality/common properties and BO, providing implementations for some of the common properties and providing data specific properties (to support data binding). BusinessLayer is exactly the place to put common code for BOs. BOs are the actual classes that interact with data and are bindable to controls. 

To get a class that you can instantiate, you need to either have the BO mapper do the work or you need to do that manually (ugh). 

//-- So, this is NOT going to work at some point
//   ...BusinessLayer has a bunch of NotImplemented methods/properties
BusinessLayer busLayer1 = new BusinessLayer();

//-- This will work, because we are providing an actual BO.
//   but only need the base functionality of the BusinessLayer.
BusinessLayer busLayer2 = new CustomersBO();

//-- And of course this will work too...
CustomersBO customers = new CustomersBO();


So, you do want to sub-class BusinessLayer and add you SetDefaultValues handler.  Then you want to change the inheritance of BOs that need this functionality as you did. You then would instantiate only BOs, though you can have BusinessLayer type variables pointing to BOs.

Is this making more sense? 
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Ok Greg, still not clear on what I have to do to SubClass the SF BO.

My starting point was:

public class KernelBO : MicroFour.StrataFrame.Business.BusinessLayer
{
}


Is there something more I need to add in here ?

Say I go to the code (That is created from the |Business Object mapper) whcih will have code like:

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


Do I Need to change this code ?



 
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search