Example of how to use a base form
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Example of how to use a base formExpand / Collapse
Author
Message
Posted 11/14/2007 1:37:13 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Yesterday @ 6:42:41 PM
Posts: 1,058, Visits: 2,581
This is an example of how to sub class the SF StandardForm to add functionality beyond what SF provides. I'm providing an example of some functionality that I needed, but of course, you may need vastly different features. Hopefully this might help in figuring out an elegant and pragmatic solution for you also!

I found myself very often coding the following features into a form:

- setting the title of the form to reflect the current record
- constructors that took the ID of a record that was passed to it, then loaded that single record into the form's BO.
- constructors that took a boolean that indicated I wanted to add a new record when the form opens.

I also need the ability to pass in a BO or data table with the data the form would use.

After doing this a few too many times, the light bulb went off and I realized there must be a better way. I then started to investigate how to use a base form. SF provided the example. The StandardForm inherits the SF BaseForm, which in turn provides all the SF niceness that we love. Why couldn't I do that myself and add my extra features?

So, I coded a base form that added the features mentioned. Now when I need one or more of those features, I just inherit from my base form (which inherits from StandardForm...so I have the SF features too).

When the solution opens, an explanation page is shown that should help you get started.

For a savvy .NET developer, this is pretty basic stuff. However, a lot of us are moving from some other language/paradigm. So I thought I'd offer this up, as it might help to have a practical example of using a base class (plus some generic shared factory methods, how to hook into the SF events (see the OnLoad method)).

Of course, all of you savvy, svelte .NET gurus out there could certainly pipe in with suggestions for improvements or trade offs of doing things differently...I'm always learning more!

Thanks!
Greg

P.S. You'll need the StrataFrameSample db loaded for this to work.


  Post Attachments 
BaseFormExample.zip (48 views, 222.53 KB)
Post #12693
Posted 11/14/2007 9:45:17 AM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 12:52:57 AM
Posts: 574, Visits: 4,601
I would love to download this, thanks Greg.

When I click the link to download I am just taken back to the main forum listing page, right click and save as gives a .html page. I have tried in IE and Firefox.

I have had this issue with attachments for a while now. Help appreciated.

Post #12695
Posted 11/14/2007 11:28:49 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Yesterday @ 6:42:41 PM
Posts: 1,058, Visits: 2,581
Hmmm....that is weird. I have no problem with the attachment. Anyone else? Maybe its a setting in IE/firefox or a proxy issue?
Post #12699
Posted 11/14/2007 11:39:02 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: Yesterday @ 5:32:16 PM
Posts: 16, Visits: 1,997
I have downloaded the attachment with IE without any problems.

And Greg - it is a very good sample with some functionality that i can use in my current application.

Thx.

Teddy

Post #12700
Posted 11/14/2007 1:42:47 PM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 05/07/2008 9:21:08 PM
Posts: 63, Visits: 201
For those who may not know.  You can get tricky and add it to the New Item dialog as well via Templates as well.   Just search VSTemplates or look in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\  for some samples.

Richard

Post #12704
Posted 11/14/2007 6:45:11 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 12:52:57 AM
Posts: 574, Visits: 4,601
I was able to download from home, thanks Greg.
Post #12709
Posted 11/14/2007 7:51:45 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 4:54:54 PM
Posts: 551, Visits: 10,431
Hey Greg.

Very nice!

Thanks.

Post #12710
Posted 11/15/2007 1:58:15 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 4:13:27 PM
Posts: 123, Visits: 403
I got it. Make sure you are logged in before downloading!
Post #12726