Marker best practices [message #550456] |
Fri, 30 July 2010 12:36 |
Christian Kesselheim Messages: 59 Registered: June 2010 |
Member |
|
|
Hello everybody,
we'd like to only enable our save/save all commands in case no further (error/mandatory/...) markers are still pending in the scope of the current controller.
What's the best way to check this condition in Riena?
So far, we're using a rather naive approach such as this:
for (IRidget ridget : getRidgets()) {
if (ridget instanceof IMarkableRidget) {
IMarkableRidget markableRidget = (IMarkableRidget) ridget;
for (IMarker marker : markableRidget.getMarkers()) {
if (marker instanceof MandatoryMarker && ((MandatoryMarker)marker).isDisabled()) {
continue;
}
System.out.println("Iss nit!");
}
}
}
What I consider especially ugly with this is that I have to hardwire certain "special" marker types for which I need to check some additional conditions (such as that MandatoryMarker.isDisabled() is set to false).
Any suggestions?
Bonus question: For the previous version of our product we were using a business object framework called CSLA.NET (http://www.lhotka.net/cslanet/) for representing our validation rules/business object constraints. Does anyone here already has some experience/idea on how easy it would be to use something similar for a Riena-driven application?
For example, I'd like to declare business rules at the BO-level like so
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired,
new Csla.Validation.RuleArgs(CompanyNameProperty));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs(
CompanyNameProperty,
50));
}
and then wire-up the corresponding validation message collection from my BO with the rest of the Riena marker infrastructure
// Somewhere within my controller
MyBusinessObject thing = ...;
BrokenValidationRules brokenRules = thing.getBrokenValidationRules();
subscribeRienaToBrokenRulesFromBO(brokenRules);
. Among other things, this would then allow me to base my validation on more than just that part of my BO data that is known to/displayed by the current SubModuleController. Also, it would free me from the need to have the Riena UI layer "judge" the validity of my object and instead allow me e.g. to repeat these validations on server-side as well.
Of course, I would still have to rely on standard Riena validation rules for performing those validations that can only take place within UI code, e.g. validation of standard text fields whose value is being bound to model properties that can only take-on certain well-defined values.
Thanks in advance,
Chris
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03956 seconds