BBS and multiple instances of the business Object


Author
Message
Ertan Deniz
Ertan Deniz
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 163, Visits: 493
Business Object's constructor is fired X number of times when it is bound to grid with BBS. I have a BusinessObjectBase class which is base class for all BusinessObjects and implemented initialization (method) logic inside it and every Business Object has an overriden initialization method. Now, both of them are executed many times. But They must be executed only once.

How should I handle this situation ? What is the best practice ?

Reply
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (938 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Again, without knowing the details of your code we can't give a code snippet type of answer, but what Trent was getting at with the shared property is basically this:

1) Add a shared (static) boolean property to your base business object called "InitFired" or some such which will be defaulted to False

2) In the init of your base business object, all logic should go inside of an If Test ("If Not InitFired Then ...").

3) Inside of that if test, you should set the InitFired property to True. That way, any subsequent firings of the init on the business objects will be negated (it will test on the initfired property, see that it is true, and skip all of the logic within)

The source of the problem is likely in that a new instance of the business object is created for each row in the grid. As such, each row is currently firing the init method for the business object. Using the above, any undesired inits should be bypassed. Keep in mind that you will need to reset the shared InitFired property yourself whenever appropriate (i.e. once the grid is fully populated).

Hope it helps Smile

Dustin

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