IBusinessBindable with OnValidate


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Based on the feedback from another post (http://forum.strataframe.net/FindPost13906.aspx) I was attempting to use OnValidate to update the data source. However, when I set this for a custom control I made, the set property never got fired (the data source was never updated). I implemented a property change event, but I'm thinking I must need a validate event also. What do I need to implement on this control to get OnValidate to work?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Bump....
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Well, this would depend on the control and property.  If you are inheriting a textbox and using the Text property, the you wouldn't have a problem.  You will have to fire the changed event of the property, and if one doesn't exists, then you need to create one.

Public Property MyBindingProperty As String
   Get
      Return _MyBindingProperty
   End Get
   Set (Byval value as String)
        _MyBindingProperty = value
        OnMyBindingPropertyChanged()
   End Set
End Property


Public Event MyBindingPropertyChanged As EventHandler


Private Sub OnMyBindingPropertyChanged()
    RaiseEvent MyBindingPropertyChanged(Me, EventArgs.Empty)
End Sub

This really shouldn't have anything to do with the IBusinessBindable, but rather the .NET binding that goes on behind the scenes one the SF binding creates the Binding class and adds it to the control.  So it as though you are just manually binding the control to the property (you would have the same results).

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Already done this. Works great....until I change the control to update the data source OnValidate, then the set on the property never gets called, therefore the OnChanged event never gets called, and the field in the BO is never updated. So the question is, what needs to happen here so I can use the OnValidate to update the BO?
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
This is a control level issue.  I am not sure if this is a custom control or not and it also depends on the type of control in which you are inheriting.  Validation in a textbox is invoked, for example, when you try to leave the field.  So it calls the OnValidating method which raises the Validating event.  This method call is never happening in your control.  If you are inheriting the UserControl, then you could override the OnValidating and/or the OnValidated method and add your logic to force this to update.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
One other thing.  If you are inherited a control that already has the OnValidated method, then just call it within your control when you want the control to validate and the binding should follow suit.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'll look into this. This is a sub classes TextControl, by implementing IBusinessBindable. I'll have to see if it has/raises the Validating event. It should be fun if it doesn't Sad
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