Activeobjects 2

Activeobjects 2

Old forum URL: forums.lhotka.net/forums/t/749.aspx


cash_pat posted on Friday, July 28, 2006

    Anybody knows how the observer /ActiveControlbinder / ActiveEditForm / BinderManager  / Notification  would work in Activeobjects 2.

Any sample code would be a great help

cash pat

Jurjen replied on Friday, July 28, 2006

Cash Pat,

I've been using ActiveObjects 2 for some time now. I have attached a sample from one of my projects, all my BO's are created as partial classes, one part generated one part handcrafted (wich is also generated, but only just once). I hope this helps.
Petar did send me some sample code just before he released AO-2, I'll ask him if I can post those files here or maybe he could publish some sample code on his website.

ActiveBinder works more or less the same as it did before.

ActiveEditForm is not known to me.

AFAIK Observer works more or less the same as it did before, however it has been optimized.


I know of one problem with ActiveObjects that is not yet been fixed in the current version :

  Protected Overridable Sub DoDelete(ByVal criteria As Object, ByVal tr As IDbTransaction)

    If (Not mDirectDelete) Then
      ' if we're not dirty then don't update the database
      If (Not Me.IsDirty) Then Return        ‘ <===== comment this line !!
      ' if we're new then don't update the database
      If Me.IsNew Then Return
    End If


HTH,
Jurjen.

cash_pat replied on Saturday, July 29, 2006

Did u ask Petar if u could send me the code


HTH
Cash

Jurjen replied on Saturday, July 29, 2006

Yes, I did ask him, but he hasn't replied yet.

Did the code I posted help you in any way ?


Jurjen.

cash_pat replied on Saturday, July 29, 2006

Most of my winforms depends on activeeditform. so i am stuck up badly.

If you look up at the old activetracker app you will find ActiveEditForm in the WinForms Project

cash_pat replied on Saturday, July 29, 2006

I am still confused about the integration between ActiveEditForm and WinParts

cash_pat replied on Saturday, July 29, 2006

Posting my ActiveObjects 1.53 ActiveEditForm

xal replied on Saturday, July 29, 2006

cash_pat,
I used the active edit form too. But when moving to 2.0 things change a lot. All the ApplyEdit / ApplyEditSave / BeginEdit / CancelEdit stuff is kind of pointless now, because you're supposed to handle those with the BindingSource.
Also, I don't use the Control Binder anymore. It still works, but you can't beat dragging and dropping controls. I suppose some of the features could be moved to extender controls or just create new controls that use those features, but I don't find myself missing them (at least for now).
The only part of the control binder I was using was the error tree view,  but I recently created a treeview for that purpose that works with AO and plain CSLA. The good thing about it is that it doesn't redraw the whole tree when rules are changed, it just keeps track of existing rules and objects and redraws only the parts that changed. It also handlles the coming severity stuff using icons and colors. I will put that in the contrib site as soon as csla 2.1 is frozen.

I ended up building different objects to aid me in the saving process, which is pretty straightforward, and I have a base form that registers to the object.
I use the stuff I mention in this thread, which help me a lot. Generics in windows forms are a true time saver. (and a cast saver :D)

Andrés

cash_pat replied on Sunday, July 30, 2006

To XAL

But without the ActiveControlBinder the error icon doesn't go away unit the control loses focus. Am I doing something wrong.

Also I could not get what you meant by Generic Inheritance. I am using Visual inheritance and inheritance in my forms. Your sample code also contains a class MagicAttributes. What does it do. Please Elaborate
How would it turn to be useful.

xal replied on Sunday, July 30, 2006

If you look at the form's class definition, it's

Public Class MyForm
  Inherits BaseForm(Of MyBO)

End Class

In your base form you could expose something like:

Public ReadOnly Property Model As T
...
End Property


There's obviously a lot more to it than just that... just use your imagination. The point is that VS can't handle forms inheritance when generics are involved or when your base form is MustInherit, because the designer makes an instance of your base form in order to show it. That's where the "MagicAttriburtes" come in place...

You could do something like this in your base form:

Protected MustOverride GetModel() As T
Protected MustOverride GetMainBindingSource() As BindingSource



That would help abstract the endedit call and the RaiseListChange property in your binding source when you save.

About the error icons, you could change the way databinding works in the designer by going to your textbox and expanding the DataBindings property... There you can define the event you want to use to keep your controls in sync with your bo...
Or you could also write extender controls for that purpose....

I hope that helps...

Andrés

gdk9am replied on Wednesday, December 20, 2006

Hi

Have got any sample code using active objects 2.0 and dynamic sql ?

Thanks

Graeme

Jurjen replied on Monday, December 25, 2006

Graeme,

ActiveObjects sample code can be downloaded here (since 19-okt-2006) :

http://www.xs4all.nl/~jdgroot/CSLA/

This is sample code I received from Petar way back in April, I'm not sure if it will answer all your questions but this is all I got.

Jurjen

Copyright (c) Marimer LLC