Some times, you have a very complex form that the use needs to fill and submit for further processing. For example, I am currently developing a Staff Appraisal Form, which has 9 pages minimum, it is dynamic and validation for data entry are also dynamic which changes depending on the Stage of the Applicaiton.
Currently, the form has 2 major buttons:
It does not make sense to force the Staff to fill valid information for all the form fields before he can save the form. It will be more convenient to allow the Staff to save the form (, even if some validation rules are not true, or even if some required fields are not filled. However, the Submit Button can be executed only if ALL the validation rules are fulfilled.
I am using CSLA .NET for framework 2.0 and Visual Studio 2005. I did not seen anything in CSLA framework that addresses such case; allow to save the Business Object even if some validation rules are not valid. Basically, as per CSLA .NET, if one or more of the validation rules are not valid, then the save logic will throw an error.
I was thinking that probably we need to assign a severity level for each validation rule, and configure the object to throw an error during save if any validation rule is not valid and its severity level exceeds a predefined limit. We can also add a "IsValid" flag as a field in the related record of the businsess object being saved.
I am wondering if this situation has been addressed before in CSLA .NET 2.0 or later versions.
What is the best way to implement such requirement ?
There are a couple possibilities.
First, broken rules have severities that are set by the rule. The default is Error, but your rule can indicate that it is just a warning. Warning and Information severities don't block saving an object.
Sadly, Microsoft's UI technologies don't understand this concept at all - they only know about validation errors. But the XAML PropertyInfo and PropertyStatus controls in Csla.Xaml understand the concept.
Second, you can override Save (and BeginSave) and change its behavior. If you look at the CSLA source code you can see the Save method. It isn't terribly complex - and one line in that method is where the object refuses to be saved if it has broken rules. You can override Save to reimplement it without that check.
Could you please point me to some resources to know more about XAML and CSLA.Xaml
Copyright (c) Marimer LLC