BBS and multiple instances of the business Object


Author
Message
Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 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 ?

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
How should I handle this situation ? What is the best practice ?

I don't understand your code, but it sounds like you just need to create a shared property (or dictionary) to test against so that your Init logic doesn't fire more than once.

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
Thanks. I think, This is the only way to follow.

Do you compare BBS and native binding source component / DataTable binding? Does BBS work well ? Is there a performance issues ?

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K

Do you compare BBS and native binding source component / DataTable binding? Does BBS work well ? Is there a performance issues ?

The performance should not be an issue whatsoever.  This is something that is commonly done (including ourselves).  The BBS i something that continues to grow and is what we use exclusively for reporting and grids.  So you wil be in good shape Wink

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
I've tried to develop a solution to init logic that fires more than once. I've defined a dictionary to store the business objects that are entering query mode (FillDataTable). I've tested the the object that it was in query mode.

After query, I've deleted the business object from the dictionary. BBS starts to ctruct the business object list. Since I've deleted the object from the dictionary, I Couldn't test the condition and my init logic runs many times.

Could I get your solution ? "Shared property or dictionary based solution".

Firstly, Constructor fires for the business object itself. After BBS starts and fired many times the same constructor ? How can I understand from where constructor is called ? (i.e BBS calls the constrctor ?) 

Dustin Taylor
Dustin Taylor
StrataFrame Team Member (658 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

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
My solution is based on Dictionary (Shared). Because many objects can not share one property.

I couldn't catch the end of the action (i.e Grid populated fully or BBS translates last row)

Firstly, I want to solve this case in the base (Say Our Custom framework)

I don't want to write any code to catch the action in our forms.

Thanks for the response.

Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
Any Comment ?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I didn't know you were waiting for a comment.  What is your question in your current cycle on this problem?
Ertan Deniz
Ertan Deniz
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 163, Visits: 493
The problem can not be solved with neither shared property nor shared dictionary. Because, We can not catch the end of population to reset the flag according to my knowledge. (like InitFired) 

I think this must be solved on the framework. A Shared property can be used to set to when calling "Activator.CreateInstance" and reset after the operation. Developers check this property to manage the flow. This  was the most convienent method that I've found.

 

Thanks.

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