First, a huge thank you for an awesome business object framework. I've learned so much just by stepping through your code.
I would like to suggest that some validation rules for properties, e.g. the maximum length rule, could be very useful to the UI developer. Perhaps an attribute for validation rules that affect values easily set for UI controls could allow some of these validation rules to be used by the UI devleoper?
I like my UI to be offer immediate feedback whenever possible, and setting the maximum length that can be entered into a textbox (for example) or a regex that specifies the format for input allows me to give that feedback.
Just a thought.
Helen
Not long ago, I did something like that.
Airosafe ICE™ (my company main product, not literally mine…) UI uses heavily this concept. I'll explain:
First, let me mention that the UI is a web application. I wanted to just "Bind" property to textbox and so obtain the following:
Let's look at class 'Device' (may represent: PC, Router, Switch etc), it has a 'MacAddress' property. I assigned 'MacAddressRuleAttribute' Attribute to this property.
[MacAddressRule()]
public string MacAddress
{
get...
set...
}
Then in the when I want to bind this property:
Binder.Bind(txtMacAddress,macAddressObject,"MacAddress")
It's not exactly the way I implemented but you get the idea…
You are invited to look at the end result. You may download and install it, or you can just look at a flash demonstration .Notice the red frame when the text box has invalid data, also notice that the Save button is disabled until all controls on the page is valid. Looks familiar..?
I'm on the process of combining my work with csla.net, when I'm done I'll write an article.
P.s
In the flash demonstration there a delay with the red frame and the enable state of the save button that caused by the program used to create it. Plus there a nice tooltip that says why the textbox is not valid that is not shown also on the flash demonstration.
Tamir
Hi Helen,
one of the aims is to move business rules, such as validation, out of the UI, and into the BO's. This way the validation rules can be consistently applied by any other UI's, and be available back at the server (if there is one) as a belt-and-braces check just before the db is updated.
Also don't forget that the BO's are present inside the UI, so in that sense the rules are available for immediate feedback without any server roundtrip.
I think it would be nice to stop someone from typing a 60 character note into a 10 char field and then being told they can only enter 10 chars max, by setting the textbox maxlength to 10.. It would be the UI developer's choice to implement, and the business object would still do it's own rule checking.
I think someone mentioned making information like this available with attributes on the old forum..
ReadOnly Property IsRequired As BooleanEnd Interface
ReadOnly Property IsReadOnly As Boolean
ReadOnly Property MaxLength As Integer
Function TryFormat(ByRef Text as String) As Boolean
Readonly Property IsRequired As BooleanEnd Interface
ReadOnly Property IsReadOnly As Boolean
ReadOnly Property Precision As Integer
Function TryFormat(ByRef Text As String) As Boolean
Copyright (c) Marimer LLC