Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Riena » Marker best practices
icon5.gif  Marker best practices [message #550456] Fri, 30 July 2010 12:36 Go to next message
Christian Kesselheim is currently offline Christian KesselheimFriend
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
Re: Marker best practices [message #550667 is a reply to message #550456] Wed, 04 August 2010 06:31 Go to previous messageGo to next message
Steffen Kriese is currently offline Steffen KrieseFriend
Messages: 5
Registered: July 2009
Junior Member
Christian Kesselheim wrote on Fri, 30 July 2010 08:36
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?


Hi Chris,
The easiest way would be to ask the NavigationNode if it has some markers:

@Override
public void configureRidgets() {
super.configureRidgets();
.....

getNavigationNode().addSimpleListener(new SimpleNavigationNodeAdapter() {
  @Override
  public void markerChanged(INavigationNode<?> source,  IMarker marker) {
   if (marker instanceof MandatoryMarker || marker instanceof ErrorMarker) {
		checkButtonState();
  }
  }
  });
}



The method markerChanged gets called everytime a marker in the current SubModule is added or removed.


Best regards,
Steffen
icon5.gif  Re: Marker best practices [message #550690 is a reply to message #550667] Wed, 04 August 2010 07:13 Go to previous message
Christian Kesselheim is currently offline Christian KesselheimFriend
Messages: 59
Registered: June 2010
Member
Thanks for that.

Question out of curiosity: Is there actually any conceptual reason behind the fact that error markers disappear from the markers collection once they do no longer apply/are no longer displayed while mandatory markers currently don't?

Thanks for your time,

Chris
Previous Topic:ISaveable vs. Riena: Why supporting the Eclipse Jobs API might not be enough
Next Topic:Marker best practices
Goto Forum:
  


Current Time: Thu Mar 28 10:37:13 GMT 2024

Powered by FUDForum. Page generated in 0.03956 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top